Commit 6a719e05 authored by Dave Airlie's avatar Dave Airlie

drm/kms/radeon: cleanup combios TV table like DDX.

The fallback case wasn't getting executed properly if there
was no TV table, which my T42 M7 hasn't got.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent bf8e828b
...@@ -685,23 +685,15 @@ static const uint32_t default_tvdac_adj[CHIP_LAST] = { ...@@ -685,23 +685,15 @@ static const uint32_t default_tvdac_adj[CHIP_LAST] = {
0x00780000, /* rs480 */ 0x00780000, /* rs480 */
}; };
static struct radeon_encoder_tv_dac static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
*radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev) struct radeon_encoder_tv_dac *tv_dac)
{ {
struct radeon_encoder_tv_dac *tv_dac = NULL;
tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
if (!tv_dac)
return NULL;
tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
tv_dac->ps2_tvdac_adj = 0x00880000; tv_dac->ps2_tvdac_adj = 0x00880000;
tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
return;
return tv_dac;
} }
struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
...@@ -713,19 +705,18 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -713,19 +705,18 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
uint16_t dac_info; uint16_t dac_info;
uint8_t rev, bg, dac; uint8_t rev, bg, dac;
struct radeon_encoder_tv_dac *tv_dac = NULL; struct radeon_encoder_tv_dac *tv_dac = NULL;
int found = 0;
tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
if (!tv_dac)
return NULL;
if (rdev->bios == NULL) if (rdev->bios == NULL)
return radeon_legacy_get_tv_dac_info_from_table(rdev); goto out;
/* first check TV table */ /* first check TV table */
dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
if (dac_info) { if (dac_info) {
tv_dac =
kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
if (!tv_dac)
return NULL;
rev = RBIOS8(dac_info + 0x3); rev = RBIOS8(dac_info + 0x3);
if (rev > 4) { if (rev > 4) {
bg = RBIOS8(dac_info + 0xc) & 0xf; bg = RBIOS8(dac_info + 0xc) & 0xf;
...@@ -739,6 +730,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -739,6 +730,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
bg = RBIOS8(dac_info + 0x10) & 0xf; bg = RBIOS8(dac_info + 0x10) & 0xf;
dac = RBIOS8(dac_info + 0x11) & 0xf; dac = RBIOS8(dac_info + 0x11) & 0xf;
tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
found = 1;
} else if (rev > 1) { } else if (rev > 1) {
bg = RBIOS8(dac_info + 0xc) & 0xf; bg = RBIOS8(dac_info + 0xc) & 0xf;
dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
...@@ -751,22 +743,15 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -751,22 +743,15 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
bg = RBIOS8(dac_info + 0xe) & 0xf; bg = RBIOS8(dac_info + 0xe) & 0xf;
dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
found = 1;
} }
tv_dac->tv_std = radeon_combios_get_tv_info(encoder); tv_dac->tv_std = radeon_combios_get_tv_info(encoder);
}
} else { if (!found) {
/* then check CRT table */ /* then check CRT table */
dac_info = dac_info =
combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
if (dac_info) { if (dac_info) {
tv_dac =
kzalloc(sizeof(struct radeon_encoder_tv_dac),
GFP_KERNEL);
if (!tv_dac)
return NULL;
rev = RBIOS8(dac_info) & 0x3; rev = RBIOS8(dac_info) & 0x3;
if (rev < 2) { if (rev < 2) {
bg = RBIOS8(dac_info + 0x3) & 0xf; bg = RBIOS8(dac_info + 0x3) & 0xf;
...@@ -775,6 +760,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -775,6 +760,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
(bg << 16) | (dac << 20); (bg << 16) | (dac << 20);
tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
found = 1;
} else { } else {
bg = RBIOS8(dac_info + 0x4) & 0xf; bg = RBIOS8(dac_info + 0x4) & 0xf;
dac = RBIOS8(dac_info + 0x5) & 0xf; dac = RBIOS8(dac_info + 0x5) & 0xf;
...@@ -782,13 +768,17 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct ...@@ -782,13 +768,17 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
(bg << 16) | (dac << 20); (bg << 16) | (dac << 20);
tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
found = 1;
} }
} else { } else {
DRM_INFO("No TV DAC info found in BIOS\n"); DRM_INFO("No TV DAC info found in BIOS\n");
return radeon_legacy_get_tv_dac_info_from_table(rdev);
} }
} }
out:
if (!found) /* fallback to defaults */
radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
return tv_dac; return tv_dac;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment