49 return backlight_level;
53 radeon_atom_set_backlight_level_to_reg(
struct radeon_device *rdev,
82 return radeon_atom_get_backlight_level_from_reg(rdev);
135 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
142 if (bd->
props.brightness < 0)
147 level = bd->
props.brightness;
154 struct radeon_backlight_privdata *
pdata = bl_get_data(bd);
162 static int radeon_atom_backlight_get_brightness(
struct backlight_device *bd)
164 struct radeon_backlight_privdata *pdata = bl_get_data(bd);
165 struct radeon_encoder *radeon_encoder = pdata->encoder;
169 return radeon_atom_get_backlight_level_from_reg(rdev);
172 static const struct backlight_ops radeon_atom_backlight_ops = {
174 .update_status = radeon_atom_backlight_update_status,
184 struct radeon_backlight_privdata *
pdata;
200 DRM_ERROR(
"Memory allocation failed\n");
204 memset(&props, 0,
sizeof(props));
208 "radeon_bl%d", dev->primary->index);
210 pdata, &radeon_atom_backlight_ops, &props);
212 DRM_ERROR(
"Backlight registration failed\n");
216 pdata->encoder = radeon_encoder;
218 backlight_level = radeon_atom_get_backlight_level_from_reg(rdev);
223 bd->
props.brightness = radeon_atom_backlight_get_brightness(bd);
225 backlight_update_status(bd);
227 DRM_INFO(
"radeon atom DIG backlight initialized\n");
236 static void radeon_atom_backlight_exit(
struct radeon_encoder *radeon_encoder)
257 struct radeon_legacy_backlight_privdata *
pdata;
259 pdata = bl_get_data(bd);
263 DRM_INFO(
"radeon atom LVDS backlight unloaded\n");
273 static void radeon_atom_backlight_exit(
struct radeon_encoder *encoder)
284 static inline bool radeon_encoder_is_digital(
struct drm_encoder *encoder)
305 static bool radeon_atom_mode_fixup(
struct drm_encoder *encoder,
359 memset(&args, 0,
sizeof(args));
379 switch (dac_info->
tv_std) {
402 atombios_tv_setup(
struct drm_encoder *encoder,
int action)
411 memset(&args, 0,
sizeof(args));
420 switch (dac_info->
tv_std) {
499 memset(&args, 0,
sizeof(args));
534 args.
dvo_v3.ucDVOConfig = 0;
537 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
542 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
563 int hdmi_detected = 0;
572 memset(&args, 0,
sizeof(args));
628 args.
v2.ucTruncate = 0;
629 args.
v2.ucSpatial = 0;
630 args.
v2.ucTemporal = 0;
655 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
660 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
716 dig_connector = radeon_connector->
con_priv;
808 int dp_lane_count = 0;
818 hpd_id = radeon_connector->
hpd.hpd;
825 memset(&args, 0,
sizeof(args));
853 args.
v1.ucLaneNum = 8;
855 args.
v1.ucLaneNum = 4;
913 if (dp_clock == 270000)
915 else if (dp_clock == 540000)
926 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
931 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
961 int dp_lane_count = 0;
962 int connector_object_id = 0;
963 int igp_lane_info = 0;
981 hpd_id = radeon_connector->
hpd.hpd;
984 connector_object_id =
991 pll_id = radeon_crtc->
pll_id;
995 if (dig_encoder == -1)
1001 memset(&args, 0,
sizeof(args));
1028 args.
v1.asMode.ucLaneSel = lane_num;
1029 args.
v1.asMode.ucLaneSet = lane_set;
1050 if (igp_lane_info & 0x1)
1052 else if (igp_lane_info & 0x2)
1054 else if (igp_lane_info & 0x4)
1056 else if (igp_lane_info & 0x8)
1059 if (igp_lane_info & 0x3)
1061 else if (igp_lane_info & 0
xc)
1147 if (dig_encoder & 1)
1155 if (is_dp && rdev->
clock.dp_extclk)
1206 if (dig_encoder & 1)
1215 if (rdev->
clock.dp_extclk)
1279 if (is_dp && rdev->
clock.dp_extclk)
1298 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
1303 DRM_ERROR(
"Unknown table version %d, %d\n", frev, crev);
1333 memset(&args, 0,
sizeof(args));
1343 for (i = 0; i < 300; i++) {
1360 atombios_external_encoder_setup(
struct drm_encoder *encoder,
1373 int dp_lane_count = 0;
1374 int connector_object_id = 0;
1387 dp_clock = dig_connector->
dp_clock;
1389 connector_object_id =
1393 memset(&args, 0,
sizeof(args));
1411 if (dp_clock == 270000)
1428 if (dp_clock == 270000)
1430 else if (dp_clock == 540000)
1451 DRM_ERROR(
"Unknown table version: %d, %d\n", frev, crev);
1456 DRM_ERROR(
"Unknown table version: %d, %d\n", frev, crev);
1473 memset(&args, 0,
sizeof(args));
1484 (radeon_crtc->
crtc_id << 18)));
1492 args.ucCRTC = radeon_crtc->
crtc_id;
1500 radeon_atom_encoder_dpms_avivo(
struct drm_encoder *encoder,
int mode)
1508 memset(&args, 0,
sizeof(args));
1581 radeon_atom_encoder_dpms_dig(
struct drm_encoder *encoder,
int mode)
1594 radeon_dig_connector = radeon_connector->
con_priv;
1612 atombios_external_encoder_setup(encoder, ext_encoder,
1635 radeon_dig_connector->
edp_on =
true;
1666 radeon_dig_connector->
edp_on =
false;
1676 radeon_atom_encoder_dpms_ext(
struct drm_encoder *encoder,
1687 atombios_external_encoder_setup(encoder, ext_encoder,
1689 atombios_external_encoder_setup(encoder, ext_encoder,
1692 atombios_external_encoder_setup(encoder, ext_encoder,
ATOM_ENABLE);
1698 atombios_external_encoder_setup(encoder, ext_encoder,
1700 atombios_external_encoder_setup(encoder, ext_encoder,
1703 atombios_external_encoder_setup(encoder, ext_encoder,
ATOM_DISABLE);
1709 radeon_atom_encoder_dpms(
struct drm_encoder *encoder,
int mode)
1716 DRM_DEBUG_KMS(
"encoder dpms %d to mode %d, devices %08x, active_devices %08x\n",
1728 radeon_atom_encoder_dpms_avivo(encoder, mode);
1734 radeon_atom_encoder_dpms_dig(encoder, mode);
1749 radeon_atom_encoder_dpms_dig(encoder, mode);
1751 radeon_atom_encoder_dpms_avivo(encoder, mode);
1767 radeon_atom_encoder_dpms_avivo(encoder, mode);
1774 radeon_atom_encoder_dpms_ext(encoder, ext_encoder, mode);
1786 atombios_set_encoder_crtc_source(
struct drm_encoder *encoder)
1797 memset(&args, 0,
sizeof(args));
1813 args.
v1.ucCRTC = radeon_crtc->
crtc_id << 2;
1917 DRM_ERROR(
"Unknown table version: %d, %d\n", frev, crev);
1928 atombios_apply_encoder_quirks(
struct drm_encoder *encoder,
1937 if ((dev->pdev->device == 0x71C5) &&
1938 (dev->pdev->subsystem_vendor == 0x106b) &&
1939 (dev->pdev->subsystem_device == 0x0080)) {
1969 static int radeon_atom_pick_dig_encoder(
struct drm_encoder *encoder)
2044 struct radeon_encoder *radeon_test_encoder;
2046 if (encoder == test_encoder)
2049 if (!radeon_encoder_is_digital(test_encoder))
2053 dig = radeon_test_encoder->
enc_priv;
2060 if (dig_enc_in_use & 0x2)
2061 DRM_ERROR(
"LVDS required digital encoder 2 but it was in use - stealing\n");
2064 if (!(dig_enc_in_use & 1))
2092 atombios_external_encoder_setup(encoder, ext_encoder,
2098 radeon_atom_encoder_mode_set(
struct drm_encoder *encoder,
2113 atombios_yuv_setup(encoder,
true);
2115 atombios_yuv_setup(encoder,
false);
2150 atombios_apply_encoder_quirks(encoder, adjusted_mode);
2164 atombios_dac_load_detect(
struct drm_encoder *encoder,
struct drm_connector *connector)
2178 memset(&args, 0,
sizeof(args));
2213 radeon_atom_dac_detect(
struct drm_encoder *encoder,
struct drm_connector *connector)
2221 if (!atombios_dac_load_detect(encoder, connector)) {
2222 DRM_DEBUG_KMS(
"detect returned false \n");
2231 DRM_DEBUG_KMS(
"Bios 0 scratch %x %08x\n", bios_0_scratch, radeon_encoder->
devices);
2254 radeon_atom_dig_detect(
struct drm_encoder *encoder,
struct drm_connector *connector)
2273 atombios_external_encoder_setup(encoder, ext_encoder,
2278 DRM_DEBUG_KMS(
"Bios 0 scratch %x %08x\n", bios_0_scratch, radeon_encoder->
devices);
2307 atombios_external_encoder_setup(encoder, ext_encoder,
2312 static void radeon_atom_encoder_prepare(
struct drm_encoder *encoder)
2324 dig->
dig_encoder = radeon_atom_pick_dig_encoder(encoder);
2341 if (radeon_connector->
router.cd_valid)
2351 atombios_set_encoder_crtc_source(encoder);
2354 static void radeon_atom_encoder_commit(
struct drm_encoder *encoder)
2361 static void radeon_atom_encoder_disable(
struct drm_encoder *encoder)
2374 struct radeon_encoder *other_radeon_encoder;
2415 if (radeon_encoder_is_digital(encoder)) {
2425 static void radeon_atom_ext_prepare(
struct drm_encoder *encoder)
2430 static void radeon_atom_ext_commit(
struct drm_encoder *encoder)
2436 radeon_atom_ext_mode_set(
struct drm_encoder *encoder,
2443 static void radeon_atom_ext_disable(
struct drm_encoder *encoder)
2449 radeon_atom_ext_dpms(
struct drm_encoder *encoder,
int mode)
2454 static bool radeon_atom_ext_mode_fixup(
struct drm_encoder *encoder,
2462 .dpms = radeon_atom_ext_dpms,
2463 .mode_fixup = radeon_atom_ext_mode_fixup,
2464 .prepare = radeon_atom_ext_prepare,
2465 .mode_set = radeon_atom_ext_mode_set,
2466 .commit = radeon_atom_ext_commit,
2467 .disable = radeon_atom_ext_disable,
2472 .dpms = radeon_atom_encoder_dpms,
2473 .mode_fixup = radeon_atom_mode_fixup,
2474 .prepare = radeon_atom_encoder_prepare,
2475 .mode_set = radeon_atom_encoder_mode_set,
2476 .commit = radeon_atom_encoder_commit,
2477 .disable = radeon_atom_encoder_disable,
2478 .detect = radeon_atom_dig_detect,
2482 .dpms = radeon_atom_encoder_dpms,
2483 .mode_fixup = radeon_atom_mode_fixup,
2484 .prepare = radeon_atom_encoder_prepare,
2485 .mode_set = radeon_atom_encoder_mode_set,
2486 .commit = radeon_atom_encoder_commit,
2487 .detect = radeon_atom_dac_detect,
2494 radeon_atom_backlight_exit(radeon_encoder);
2497 kfree(radeon_encoder);
2505 radeon_atombios_set_dac_info(
struct radeon_encoder *radeon_encoder)
2519 radeon_atombios_set_dig_info(
struct radeon_encoder *radeon_encoder)
2531 if (encoder_enum == 2)
2547 struct radeon_encoder *radeon_encoder;
2553 radeon_encoder->
devices |= supported_device;
2560 radeon_encoder = kzalloc(
sizeof(
struct radeon_encoder),
GFP_KERNEL);
2561 if (!radeon_encoder)
2564 encoder = &radeon_encoder->
base;
2585 radeon_encoder->
devices = supported_device;
2602 radeon_encoder->
enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
2604 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
2608 radeon_encoder->
enc_priv = radeon_atombios_set_dac_info(radeon_encoder);
2609 drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs);
2615 radeon_encoder->
enc_priv = radeon_atombios_set_dac_info(radeon_encoder);
2616 drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs);
2631 radeon_encoder->
enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
2634 radeon_encoder->
enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
2636 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
2655 drm_encoder_helper_add(encoder, &radeon_atom_ext_helper_funcs);