aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2009-10-28 00:51:20 -0400
committerDave Airlie <airlied@redhat.com>2009-10-28 15:30:03 +1000
commitd11aa88b33b071d55181a7a482b9e7494888c10e (patch)
tree8b95c80e299383c41b7ede5485ebf45b25b6e5ed /drivers/gpu
parenta2d49ae7df5b96fba3c63710df61412587fc6a24 (diff)
downloadkernel_samsung_tuna-d11aa88b33b071d55181a7a482b9e7494888c10e.zip
kernel_samsung_tuna-d11aa88b33b071d55181a7a482b9e7494888c10e.tar.gz
kernel_samsung_tuna-d11aa88b33b071d55181a7a482b9e7494888c10e.tar.bz2
drm/radeon/kms/atom: fix potential oops in spread spectrum code
Make sure we have an LVDS encoder before casting enc_priv. [airlied: also fix two missing cpu_to_le16 casts we noticed on irc] Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 8516e1b..c15287a 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -368,14 +368,17 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) {
radeon_encoder = to_radeon_encoder(encoder);
- dig = radeon_encoder->enc_priv;
/* only enable spread spectrum on LVDS */
- if (dig && dig->ss) {
- percentage = dig->ss->percentage;
- type = dig->ss->type;
- step = dig->ss->step;
- delay = dig->ss->delay;
- range = dig->ss->range;
+ if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+ dig = radeon_encoder->enc_priv;
+ if (dig && dig->ss) {
+ percentage = dig->ss->percentage;
+ type = dig->ss->type;
+ step = dig->ss->step;
+ delay = dig->ss->delay;
+ range = dig->ss->range;
+ } else if (enable)
+ return;
} else if (enable)
return;
break;
@@ -387,7 +390,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
if (ASIC_IS_AVIVO(rdev)) {
memset(&args, 0, sizeof(args));
- args.usSpreadSpectrumPercentage = percentage;
+ args.usSpreadSpectrumPercentage = cpu_to_le16(percentage);
args.ucSpreadSpectrumType = type;
args.ucSpreadSpectrumStep = step;
args.ucSpreadSpectrumDelay = delay;
@@ -397,7 +400,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
} else {
memset(&legacy_args, 0, sizeof(legacy_args));
- legacy_args.usSpreadSpectrumPercentage = percentage;
+ legacy_args.usSpreadSpectrumPercentage = cpu_to_le16(percentage);
legacy_args.ucSpreadSpectrumType = type;
legacy_args.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2;
legacy_args.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4;