Rev 1233 | Rev 1246 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1233 | Rev 1239 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | int vrefresh; |
48 | int vrefresh; |
49 | int pitch; |
49 | int pitch; |
50 | int lfb; |
50 | int lfb; |
51 | 51 | ||
Line -... | Line 52... | ||
- | 52 | int supported_modes; |
|
52 | struct drm_device *ddev; |
53 | struct drm_device *ddev; |
- | 54 | struct drm_connector *connector; |
|
53 | struct drm_crtc *crtc; |
55 | struct drm_crtc *crtc; |
Line 54... | Line 56... | ||
54 | 56 | ||
Line 55... | Line 57... | ||
55 | struct list_head cursors; |
57 | struct list_head cursors; |
Line 282... | Line 284... | ||
282 | 284 | ||
Line 283... | Line 285... | ||
283 | return name; |
285 | return name; |
284 | } |
286 | } |
Line 285... | Line 287... | ||
285 | 287 | ||
- | 288 | bool set_mode(struct drm_device *dev, struct drm_connector *connector, |
|
286 | bool set_mode(struct drm_device *dev, int width, int height) |
289 | mode_t *reqmode, bool strict) |
287 | { |
290 | { |
Line 288... | Line 291... | ||
288 | struct drm_connector *connector; |
291 | struct drm_display_mode *mode = NULL, *tmpmode; |
Line 289... | Line 292... | ||
289 | 292 | ||
Line 290... | Line 293... | ||
290 | bool ret = false; |
293 | bool ret = false; |
291 | 294 | ||
- | 295 | ENTER(); |
|
- | 296 | ||
- | 297 | list_for_each_entry(tmpmode, &connector->modes, head) |
|
- | 298 | { |
|
292 | ENTER(); |
299 | if( (drm_mode_width(tmpmode) == reqmode->width) && |
- | 300 | (drm_mode_height(tmpmode) == reqmode->height) && |
|
- | 301 | (drm_mode_vrefresh(tmpmode) == reqmode->freq) ) |
|
- | 302 | { |
|
Line -... | Line 303... | ||
- | 303 | mode = tmpmode; |
|
- | 304 | break; |
|
- | 305 | } |
|
- | 306 | }; |
|
- | 307 | ||
- | 308 | if( (mode == NULL) && (strict == false) ) |
|
- | 309 | { |
|
- | 310 | list_for_each_entry(tmpmode, &connector->modes, head) |
|
- | 311 | { |
|
- | 312 | if( (drm_mode_width(tmpmode) == reqmode->width) && |
|
- | 313 | (drm_mode_height(tmpmode) == reqmode->height) ) |
|
- | 314 | { |
|
- | 315 | mode = tmpmode; |
|
- | 316 | break; |
|
- | 317 | } |
|
- | 318 | }; |
|
293 | 319 | }; |
|
294 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
320 | |
Line 295... | Line 321... | ||
295 | { |
321 | if( mode != NULL ) |
296 | struct drm_display_mode *mode; |
322 | { |
- | 323 | struct drm_framebuffer *fb; |
|
Line 297... | Line 324... | ||
297 | 324 | struct drm_encoder *encoder; |
|
298 | struct drm_encoder *encoder; |
- | |
299 | struct drm_crtc *crtc; |
- | |
300 | - | ||
301 | if( connector->status != connector_status_connected) |
325 | struct drm_crtc *crtc; |
Line 302... | Line -... | ||
302 | continue; |
- | |
303 | - | ||
304 | encoder = connector->encoder; |
- | |
305 | if( encoder == NULL) |
- | |
306 | continue; |
- | |
307 | - | ||
308 | crtc = encoder->crtc; |
- | |
309 | - | ||
310 | if(crtc == NULL) |
- | |
311 | continue; |
- | |
312 | - | ||
313 | list_for_each_entry(mode, &connector->modes, head) |
- | |
314 | { |
- | |
315 | char *con_name, *enc_name; |
- | |
316 | 326 | ||
317 | struct drm_framebuffer *fb; |
327 | char con_edid[128]; |
Line 318... | Line 328... | ||
318 | 328 | char *con_name; |
|
Line 336... | Line 346... | ||
336 | con_name = drm_get_connector_name(connector); |
346 | con_name = drm_get_connector_name(connector); |
337 | enc_name = drm_get_encoder_name(encoder); |
347 | enc_name = drm_get_encoder_name(encoder); |
Line 338... | Line 348... | ||
338 | 348 | ||
339 | dbgprintf("set mode %d %d connector %s encoder %s\n", |
349 | dbgprintf("set mode %d %d connector %s encoder %s\n", |
Line 340... | Line 350... | ||
340 | width, height, con_name, enc_name); |
350 | reqmode->width, reqmode->height, con_name, enc_name); |
341 | 351 | ||
342 | fb->width = width; |
352 | fb->width = reqmode->width; |
Line 343... | Line 353... | ||
343 | fb->height = height; |
353 | fb->height = reqmode->height; |
344 | fb->pitch = radeon_align_pitch(dev->dev_private, width, 32, false) * ((32 + 1) / 8); |
354 | fb->pitch = radeon_align_pitch(dev->dev_private, reqmode->width, 32, false) * ((32 + 1) / 8); |
345 | 355 | ||
Line 346... | Line 356... | ||
346 | crtc->fb = fb; |
356 | crtc->fb = fb; |
Line -... | Line 357... | ||
- | 357 | crtc->enabled = true; |
|
- | 358 | rdisplay->crtc = crtc; |
|
347 | crtc->enabled = true; |
359 | |
348 | rdisplay->crtc = crtc; |
360 | ret = drm_crtc_helper_set_mode(crtc, mode, 0, 0, fb); |
349 | 361 | ||
- | 362 | if (ret == true) |
|
Line 350... | Line 363... | ||
350 | ret = drm_crtc_helper_set_mode(crtc, mode, 0, 0, fb); |
363 | { |
Line 351... | Line 364... | ||
351 | 364 | rdisplay->width = fb->width; |
|
352 | rdisplay->width = fb->width; |
- | |
353 | rdisplay->height = fb->height; |
365 | rdisplay->height = fb->height; |
354 | rdisplay->pitch = fb->pitch; |
366 | rdisplay->pitch = fb->pitch; |
355 | 367 | rdisplay->vrefresh = drm_mode_vrefresh(mode); |
|
356 | sysSetScreen(fb->width, fb->height, fb->pitch); |
- | |
357 | 368 | ||
358 | if (ret == true) |
369 | sysSetScreen(fb->width, fb->height, fb->pitch); |
359 | { |
370 | |
Line 360... | Line 371... | ||
360 | dbgprintf("new mode %d %d pitch %d\n",fb->width, fb->height, fb->pitch); |
371 | dbgprintf("new mode %d x %d pitch %d\n", |
361 | } |
- | |
362 | else |
372 | fb->width, fb->height, fb->pitch); |
363 | { |
373 | } |
- | 374 | else |
|
- | 375 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
|
- | 376 | fb->width, fb->height, crtc); |
|
- | 377 | } |
|
- | 378 | ||
- | 379 | LEAVE(); |
|
- | 380 | return ret; |
|
- | 381 | }; |
|
364 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
382 | |
365 | fb->width, fb->height, crtc); |
383 | static int count_connector_modes(struct drm_connector* connector) |
366 | }; |
- | |
367 | 384 | { |
|
368 | LEAVE(); |
385 | struct drm_display_mode *mode; |
Line -... | Line 386... | ||
- | 386 | int count = 0; |
|
- | 387 | ||
- | 388 | list_for_each_entry(mode, &connector->modes, head) |
|
- | 389 | { |
|
Line 369... | Line 390... | ||
369 | 390 | count++; |
|
370 | return ret; |
391 | }; |
- | 392 | return count; |
|
- | 393 | }; |
|
- | 394 | ||
- | 395 | static struct drm_connector* get_def_connector(struct drm_device *dev) |
|
- | 396 | { |
|
- | 397 | struct drm_connector *connector; |
|
- | 398 | struct drm_connector *def_connector = NULL; |
|
- | 399 | ||
- | 400 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
|
- | 401 | { |
|
- | 402 | struct drm_encoder *encoder; |
|
- | 403 | struct drm_crtc *crtc; |
|
- | 404 | ||
- | 405 | if( connector->status != connector_status_connected) |
|
- | 406 | continue; |
|
- | 407 | ||
- | 408 | encoder = connector->encoder; |
|
- | 409 | if( encoder == NULL) |
|
- | 410 | continue; |
|
- | 411 | ||
- | 412 | if( encoder->encoder_type == DRM_MODE_ENCODER_TVDAC ) |
|
- | 413 | { |
|
- | 414 | dbgprintf("skip tvdac encoder %s connector %s\n", |
|
- | 415 | drm_get_encoder_name(encoder), |
|
- | 416 | drm_get_connector_name(connector)); |
|
- | 417 | continue; |
|
- | 418 | }; |
|
- | 419 | ||
- | 420 | crtc = encoder->crtc; |
|
- | 421 | if(crtc == NULL) |
|
- | 422 | continue; |
|
- | 423 | ||
371 | }; |
424 | def_connector = connector; |
- | 425 | break; |
|
Line 372... | Line 426... | ||
372 | } |
426 | }; |
Line 373... | Line 427... | ||
373 | }; |
427 | |
Line 374... | Line 428... | ||
374 | LEAVE(); |
428 | return def_connector; |
Line 375... | Line 429... | ||
375 | return ret; |
429 | }; |
376 | }; |
430 | |
377 | 431 | bool init_display(struct radeon_device *rdev, mode_t *usermode) |
|
378 | 432 | { |
|
Line -... | Line 433... | ||
- | 433 | struct drm_device *dev; |
|
- | 434 | cursor_t *cursor; |
|
- | 435 | bool retval = false; |
|
- | 436 | ||
- | 437 | ENTER(); |
|
- | 438 | ||
- | 439 | rdisplay = GetDisplay(); |
|
379 | int init_display(struct radeon_device *rdev, mode_t *usermode) |
440 | |
380 | { |
441 | dev = rdisplay->ddev = rdev->ddev; |
381 | cursor_t *cursor; |
442 | |
382 | 443 | list_for_each_entry(cursor, &rdisplay->cursors, list) |
|
383 | ENTER(); |
444 | { |
384 | 445 | init_cursor(cursor); |
|
- | 446 | }; |
|
- | 447 | ||
- | 448 | rdisplay->connector = get_def_connector(dev); |
|
- | 449 | ||
- | 450 | if( rdisplay->connector == 0 ) |
|
385 | rdisplay = GetDisplay(); |
451 | return false; |
- | 452 | ||
- | 453 | rdisplay->supported_modes = count_connector_modes(rdisplay->connector); |
|
- | 454 | ||
Line 386... | Line 455... | ||
386 | 455 | if( (usermode->width != 0) && |
|
387 | rdisplay->ddev = rdev->ddev; |
456 | (usermode->height != 0) ) |
Line 388... | Line 457... | ||
388 | 457 | { |
|
Line 409... | Line 478... | ||
409 | rdisplay->restore_cursor = restore_cursor; |
478 | rdisplay->restore_cursor = restore_cursor; |
410 | 479 | ||
Line 411... | Line 480... | ||
411 | LEAVE(); |
480 | LEAVE(); |
Line 412... | Line 481... | ||
412 | 481 | ||
413 | return 1; |
482 | return retval; |
Line 414... | Line 483... | ||
414 | }; |
483 | }; |
415 | 484 | ||
416 | static int my_atoi(char **cmd) |
485 | static int my_atoi(char **cmd) |
Line 440... | Line 509... | ||
440 | { |
509 | { |
441 | p--; |
510 | p--; |
442 | 511 | ||
Line 443... | Line 512... | ||
443 | mode->width = my_atoi(&p); |
512 | mode->width = my_atoi(&p); |
444 | p++; |
513 | if(*p == 'x') p++; |
Line 445... | Line 514... | ||
445 | 514 | ||
- | 515 | mode->height = my_atoi(&p); |
|
- | 516 | if(*p == 'x') p++; |
|
446 | mode->height = my_atoi(&p); |
517 | |
Line 447... | Line 518... | ||
447 | p++; |
518 | mode->bpp = 32; |
- | 519 | ||
- | 520 | mode->freq = my_atoi(&p); |
|
- | 521 | ||
448 | 522 | if( mode->freq == 0 ) |
|
Line 449... | Line 523... | ||
449 | mode->freq = my_atoi(&p); |
523 | mode->freq = 60; |
450 | } |
524 | } |
Line 488... | Line 562... | ||
488 | c = *p++; |
562 | c = *p++; |
489 | }; |
563 | }; |
490 | };><>><>><>><>><>><>><>><>><>><>><>=>><>><>>>>> |
564 | }; |
491 | 565 | ||
Line -... | Line 566... | ||
- | 566 | ||
- | 567 | int get_modes(mode_t *mode, int *count) |
|
- | 568 | { |
|
- | 569 | int err = -1; |
|
- | 570 | ||
- | 571 | ENTER(); |
|
- | 572 | ||
- | 573 | dbgprintf("mode %x count %d\n", mode, *count); |
|
- | 574 | ||
- | 575 | if( *count == 0 ) |
|
- | 576 | { |
|
- | 577 | *count = rdisplay->supported_modes; |
|
- | 578 | err = 0; |
|
- | 579 | } |
|
- | 580 | else if( mode != NULL ) |
|
- | 581 | { |
|
- | 582 | struct drm_display_mode *drmmode; |
|
- | 583 | int i = 0; |
|
- | 584 | ||
- | 585 | if( *count > rdisplay->supported_modes) |
|
- | 586 | *count = rdisplay->supported_modes; |
|
- | 587 | ||
- | 588 | list_for_each_entry(drmmode, &rdisplay->connector->modes, head) |
|
- | 589 | { |
|
- | 590 | if( i < *count) |
|
- | 591 | { |
|
- | 592 | mode->width = drm_mode_width(drmmode); |
|
- | 593 | mode->height = drm_mode_height(drmmode); |
|
- | 594 | mode->bpp = 32; |
|
- | 595 | mode->freq = drm_mode_vrefresh(drmmode); |
|
- | 596 | i++; |
|
- | 597 | mode++; |
|
- | 598 | } |
|
- | 599 | else break; |
|
- | 600 | }; |
|
- | 601 | *count = i; |
|
- | 602 | err = 0; |
|
- | 603 | }; |
|
- | 604 | LEAVE(); |
|
- | 605 | return err; |
|
- | 606 | } |
|
- | 607 | ||
- | 608 | ||
- | 609 | int set_user_mode(mode_t *mode) |
|
- | 610 | { |
|
- | 611 | int err = -1; |
|
- | 612 | ||
- | 613 | if( (mode->width != 0) && |
|
- | 614 | (mode->height != 0) && |
|
- | 615 | (mode->freq != 0 ) ) |
|
- | 616 | { |
|
- | 617 | if( set_mode(rdisplay->ddev, rdisplay->connector, mode, true) ) |
|
- | 618 | err = 0; |
|
- | 619 | }; |
|
- | 620 | ||
- | 621 | return err; |
|
- | 622 | };>><>><>><>><>><>><>><>><>><>><>><>=>><>><>>>>> |