32 #ifdef CONFIG_PMAC_BACKLIGHT
36 static void radeon_legacy_encoder_disable(
struct drm_encoder *encoder)
46 static void radeon_legacy_lvds_update(
struct drm_encoder *encoder,
int mode)
51 uint32_t lvds_gen_cntl, lvds_pll_cntl, pixclks_cntl, disp_pwr_man;
52 int panel_pwr_delay = 2000;
135 static void radeon_legacy_lvds_dpms(
struct drm_encoder *encoder,
int mode)
151 radeon_legacy_lvds_update(encoder, mode);
154 static void radeon_legacy_lvds_prepare(
struct drm_encoder *encoder)
165 static void radeon_legacy_lvds_commit(
struct drm_encoder *encoder)
176 static void radeon_legacy_lvds_mode_set(
struct drm_encoder *encoder,
184 uint32_t lvds_pll_cntl, lvds_gen_cntl, lvds_ss_gen_cntl;
202 DRM_DEBUG_KMS(
"bios LVDS_GEN_CNTL: 0x%x\n", lvds->
lvds_gen_cntl);
220 if (radeon_crtc->
crtc_id == 0) {
246 static bool radeon_legacy_mode_fixup(
struct drm_encoder *encoder,
264 .dpms = radeon_legacy_lvds_dpms,
265 .mode_fixup = radeon_legacy_mode_fixup,
266 .prepare = radeon_legacy_lvds_prepare,
267 .mode_set = radeon_legacy_lvds_mode_set,
268 .commit = radeon_legacy_lvds_commit,
269 .disable = radeon_legacy_encoder_disable,
282 return backlight_level;
310 radeon_legacy_lvds_update(&radeon_encoder->
base, dpms_mode);
313 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
317 struct radeon_backlight_privdata *
pdata = bl_get_data(bd);
321 if (bd->
props.brightness < 0)
326 level = bd->
props.brightness;
334 static int radeon_legacy_backlight_update_status(
struct backlight_device *bd)
336 struct radeon_backlight_privdata *pdata = bl_get_data(bd);
337 struct radeon_encoder *radeon_encoder = pdata->encoder;
340 radeon_legacy_lvds_level(bd));
345 static int radeon_legacy_backlight_get_brightness(
struct backlight_device *bd)
347 struct radeon_backlight_privdata *pdata = bl_get_data(bd);
348 struct radeon_encoder *radeon_encoder = pdata->encoder;
361 .update_status = radeon_legacy_backlight_update_status,
371 struct radeon_backlight_privdata *
pdata;
378 #ifdef CONFIG_PMAC_BACKLIGHT
386 DRM_ERROR(
"Memory allocation failed\n");
390 memset(&props, 0,
sizeof(props));
394 "radeon_bl%d", dev->primary->index);
396 pdata, &radeon_backlight_ops, &props);
398 DRM_ERROR(
"Backlight registration failed\n");
402 pdata->encoder = radeon_encoder;
410 if (backlight_level == 0)
411 pdata->negative =
true;
412 else if (backlight_level == 0xff)
413 pdata->negative =
false;
423 #ifdef CONFIG_PMAC_BACKLIGHT
424 pdata->negative = (pdata->negative ||
439 bd->
props.brightness = radeon_legacy_backlight_get_brightness(bd);
441 backlight_update_status(bd);
443 DRM_INFO(
"radeon legacy LVDS backlight initialized\n");
452 static void radeon_legacy_backlight_exit(
struct radeon_encoder *radeon_encoder)
472 struct radeon_backlight_privdata *
pdata;
474 pdata = bl_get_data(bd);
478 DRM_INFO(
"radeon legacy LVDS backlight unloaded\n");
488 static void radeon_legacy_backlight_exit(
struct radeon_encoder *encoder)
495 static void radeon_lvds_enc_destroy(
struct drm_encoder *encoder)
500 radeon_legacy_backlight_exit(radeon_encoder);
504 kfree(radeon_encoder);
508 .destroy = radeon_lvds_enc_destroy,
511 static void radeon_legacy_primary_dac_dpms(
struct drm_encoder *encoder,
int mode)
553 static void radeon_legacy_primary_dac_prepare(
struct drm_encoder *encoder)
564 static void radeon_legacy_primary_dac_commit(
struct drm_encoder *encoder)
576 static void radeon_legacy_primary_dac_mode_set(
struct drm_encoder *encoder,
584 uint32_t disp_output_cntl, dac_cntl, dac2_cntl, dac_macro_cntl;
588 if (radeon_crtc->
crtc_id == 0) {
638 uint32_t vclk_ecp_cntl, crtc_ext_cntl;
639 uint32_t dac_ext_cntl, dac_cntl, dac_macro_cntl,
tmp;
650 tmp = vclk_ecp_cntl &
678 tmp = dac_macro_cntl;
701 .dpms = radeon_legacy_primary_dac_dpms,
702 .mode_fixup = radeon_legacy_mode_fixup,
703 .prepare = radeon_legacy_primary_dac_prepare,
704 .mode_set = radeon_legacy_primary_dac_mode_set,
705 .commit = radeon_legacy_primary_dac_commit,
706 .detect = radeon_legacy_primary_dac_detect,
707 .disable = radeon_legacy_encoder_disable,
715 static void radeon_legacy_tmds_int_dpms(
struct drm_encoder *encoder,
int mode)
742 static void radeon_legacy_tmds_int_prepare(
struct drm_encoder *encoder)
753 static void radeon_legacy_tmds_int_commit(
struct drm_encoder *encoder)
765 static void radeon_legacy_tmds_int_mode_set(
struct drm_encoder *encoder,
773 uint32_t tmp, tmds_pll_cntl, tmds_transmitter_cntl, fp_gen_cntl;
783 tmds_pll_cntl ^= (1 << 22);
789 for (i = 0; i < 4; i++) {
800 if (tmp & 0xfff00000)
803 tmds_pll_cntl &= 0xfff00000;
804 tmds_pll_cntl |=
tmp;
838 if (radeon_crtc->
crtc_id == 0) {
866 .dpms = radeon_legacy_tmds_int_dpms,
867 .mode_fixup = radeon_legacy_mode_fixup,
868 .prepare = radeon_legacy_tmds_int_prepare,
869 .mode_set = radeon_legacy_tmds_int_mode_set,
870 .commit = radeon_legacy_tmds_int_commit,
871 .disable = radeon_legacy_encoder_disable,
879 static void radeon_legacy_tmds_ext_dpms(
struct drm_encoder *encoder,
int mode)
908 static void radeon_legacy_tmds_ext_prepare(
struct drm_encoder *encoder)
919 static void radeon_legacy_tmds_ext_commit(
struct drm_encoder *encoder)
930 static void radeon_legacy_tmds_ext_mode_set(
struct drm_encoder *encoder,
960 if ((dev->pdev->device == 0x4850) &&
961 (dev->pdev->subsystem_vendor == 0x1028) &&
962 (dev->pdev->subsystem_device == 0x2001))
974 if (radeon_crtc->
crtc_id == 0) {
999 static void radeon_ext_tmds_enc_destroy(
struct drm_encoder *encoder)
1005 kfree(radeon_encoder);
1009 .dpms = radeon_legacy_tmds_ext_dpms,
1010 .mode_fixup = radeon_legacy_mode_fixup,
1011 .prepare = radeon_legacy_tmds_ext_prepare,
1012 .mode_set = radeon_legacy_tmds_ext_mode_set,
1013 .commit = radeon_legacy_tmds_ext_commit,
1014 .disable = radeon_legacy_encoder_disable,
1019 .destroy = radeon_ext_tmds_enc_destroy,
1022 static void radeon_legacy_tv_dac_dpms(
struct drm_encoder *encoder,
int mode)
1027 uint32_t fp2_gen_cntl = 0, crtc2_gen_cntl = 0, tv_dac_cntl = 0;
1030 DRM_DEBUG_KMS(
"\n");
1113 static void radeon_legacy_tv_dac_prepare(
struct drm_encoder *encoder)
1124 static void radeon_legacy_tv_dac_commit(
struct drm_encoder *encoder)
1136 static void radeon_legacy_tv_dac_mode_set(
struct drm_encoder *encoder,
1145 uint32_t tv_dac_cntl, gpiopad_a = 0, dac2_cntl, disp_output_cntl = 0;
1146 uint32_t disp_hw_debug = 0, fp2_gen_cntl = 0, disp_tv_out_cntl = 0;
1149 DRM_DEBUG_KMS(
"\n");
1219 if (radeon_crtc->
crtc_id == 0) {
1246 if (radeon_crtc->
crtc_id == 0) {
1290 static bool r300_legacy_tv_detect(
struct drm_encoder *encoder,
1291 struct drm_connector *connector)
1295 uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
1346 DRM_DEBUG_KMS(
"S-video TV connection detected\n");
1349 DRM_DEBUG_KMS(
"Composite TV connection detected\n");
1361 static bool radeon_legacy_tv_detect(
struct drm_encoder *encoder,
1362 struct drm_connector *connector)
1367 uint32_t config_cntl, tv_pre_dac_mux_cntl, tv_master_cntl,
tmp;
1371 return r300_legacy_tv_detect(encoder, connector);
1410 if (tmp & RADEON_TV_DAC_GDACDET) {
1412 DRM_DEBUG_KMS(
"S-video TV connection detected\n");
1415 DRM_DEBUG_KMS(
"Composite TV connection detected\n");
1425 static bool radeon_legacy_ext_dac_detect(
struct drm_encoder *encoder,
1426 struct drm_connector *connector)
1430 uint32_t gpio_monid, fp2_gen_cntl, disp_output_cntl, crtc2_gen_cntl;
1431 uint32_t disp_lin_trans_grph_a, disp_lin_trans_grph_b, disp_lin_trans_grph_c;
1432 uint32_t disp_lin_trans_grph_d, disp_lin_trans_grph_e, disp_lin_trans_grph_f;
1433 uint32_t tmp, crtc2_h_total_disp, crtc2_v_total_disp;
1434 uint32_t crtc2_h_sync_strt_wid, crtc2_v_sync_strt_wid;
1482 for (i = 0; i < 200; i++) {
1490 if (!drm_can_sleep())
1516 struct drm_connector *connector)
1520 uint32_t crtc2_gen_cntl = 0, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
1522 uint32_t disp_output_cntl = 0, disp_hw_debug = 0, crtc_ext_cntl = 0;
1533 if (encoder->
crtc != crtc) {
1547 tv_detect = radeon_legacy_tv_detect(encoder, connector);
1548 if (tv_detect && tv_dac)
1555 DRM_INFO(
"not detecting due to %08x\n", radeon_encoder->
active_device);
1561 if (radeon_legacy_ext_dac_detect(encoder, connector))
1667 .dpms = radeon_legacy_tv_dac_dpms,
1668 .mode_fixup = radeon_legacy_mode_fixup,
1669 .prepare = radeon_legacy_tv_dac_prepare,
1670 .mode_set = radeon_legacy_tv_dac_mode_set,
1671 .commit = radeon_legacy_tv_dac_commit,
1672 .detect = radeon_legacy_tv_dac_detect,
1673 .disable = radeon_legacy_encoder_disable,
1733 struct radeon_encoder *radeon_encoder;
1739 radeon_encoder->
devices |= supported_device;
1746 radeon_encoder = kzalloc(
sizeof(
struct radeon_encoder),
GFP_KERNEL);
1747 if (!radeon_encoder)
1750 encoder = &radeon_encoder->
base;
1760 radeon_encoder->
devices = supported_device;
1767 drm_encoder_helper_add(encoder, &radeon_legacy_lvds_helper_funcs);
1776 drm_encoder_helper_add(encoder, &radeon_legacy_tmds_int_helper_funcs);
1777 radeon_encoder->
enc_priv = radeon_legacy_get_tmds_info(radeon_encoder);
1781 drm_encoder_helper_add(encoder, &radeon_legacy_primary_dac_helper_funcs);
1789 drm_encoder_helper_add(encoder, &radeon_legacy_tv_dac_helper_funcs);
1797 drm_encoder_helper_add(encoder, &radeon_legacy_tmds_ext_helper_funcs);
1799 radeon_encoder->
enc_priv = radeon_legacy_get_ext_tmds_info(radeon_encoder);