Commit 7ebd4675 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6

* 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6:
  drm/radeon/kms/legacy: only enable load detection property on DVI-I
  drm/radeon/kms: fix panel scaling adjusted mode setup
  drivers/gpu/drm/drm_sysfs.c: sysfs files error handling
  drivers/gpu/drm/radeon/radeon_atombios.c: range check issues
  gpu: vga_switcheroo, fix lock imbalance
  drivers/gpu/drm/drm_memory.c: fix check for end of loop
  drivers/gpu/drm/via/via_video.c: fix off by one issue
  drm/radeon/kms/agp The wrong AGP chipset can cause a NULL pointer dereference
  drm/radeon/kms: r300 fix CS checker to allow zbuffer-only fastfill
parents d7526f27 68b3adb4
...@@ -77,7 +77,7 @@ static void *agp_remap(unsigned long offset, unsigned long size, ...@@ -77,7 +77,7 @@ static void *agp_remap(unsigned long offset, unsigned long size,
&& (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
(offset + size)) (offset + size))
break; break;
if (!agpmem) if (&agpmem->head == &dev->agp->memory)
return NULL; return NULL;
/* /*
......
...@@ -354,7 +354,10 @@ static struct bin_attribute edid_attr = { ...@@ -354,7 +354,10 @@ static struct bin_attribute edid_attr = {
int drm_sysfs_connector_add(struct drm_connector *connector) int drm_sysfs_connector_add(struct drm_connector *connector)
{ {
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
int ret = 0, i, j; int attr_cnt = 0;
int opt_cnt = 0;
int i;
int ret = 0;
/* We shouldn't get called more than once for the same connector */ /* We shouldn't get called more than once for the same connector */
BUG_ON(device_is_registered(&connector->kdev)); BUG_ON(device_is_registered(&connector->kdev));
...@@ -377,8 +380,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector) ...@@ -377,8 +380,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
/* Standard attributes */ /* Standard attributes */
for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) { for (attr_cnt = 0; attr_cnt < ARRAY_SIZE(connector_attrs); attr_cnt++) {
ret = device_create_file(&connector->kdev, &connector_attrs[i]); ret = device_create_file(&connector->kdev, &connector_attrs[attr_cnt]);
if (ret) if (ret)
goto err_out_files; goto err_out_files;
} }
...@@ -394,8 +397,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector) ...@@ -394,8 +397,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
case DRM_MODE_CONNECTOR_SVIDEO: case DRM_MODE_CONNECTOR_SVIDEO:
case DRM_MODE_CONNECTOR_Component: case DRM_MODE_CONNECTOR_Component:
case DRM_MODE_CONNECTOR_TV: case DRM_MODE_CONNECTOR_TV:
for (i = 0; i < ARRAY_SIZE(connector_attrs_opt1); i++) { for (opt_cnt = 0; opt_cnt < ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) {
ret = device_create_file(&connector->kdev, &connector_attrs_opt1[i]); ret = device_create_file(&connector->kdev, &connector_attrs_opt1[opt_cnt]);
if (ret) if (ret)
goto err_out_files; goto err_out_files;
} }
...@@ -414,10 +417,10 @@ int drm_sysfs_connector_add(struct drm_connector *connector) ...@@ -414,10 +417,10 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
return 0; return 0;
err_out_files: err_out_files:
if (i > 0) for (i = 0; i < opt_cnt; i++)
for (j = 0; j < i; j++) device_remove_file(&connector->kdev, &connector_attrs_opt1[i]);
device_remove_file(&connector->kdev, for (i = 0; i < attr_cnt; i++)
&connector_attrs[i]); device_remove_file(&connector->kdev, &connector_attrs[i]);
device_unregister(&connector->kdev); device_unregister(&connector->kdev);
out: out:
......
...@@ -2912,7 +2912,7 @@ typedef struct _ATOM_ANALOG_TV_INFO_V1_2 ...@@ -2912,7 +2912,7 @@ typedef struct _ATOM_ANALOG_TV_INFO_V1_2
UCHAR ucTV_BootUpDefaultStandard; UCHAR ucTV_BootUpDefaultStandard;
UCHAR ucExt_TV_ASIC_ID; UCHAR ucExt_TV_ASIC_ID;
UCHAR ucExt_TV_ASIC_SlaveAddr; UCHAR ucExt_TV_ASIC_SlaveAddr;
ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING]; ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING_V1_2];
}ATOM_ANALOG_TV_INFO_V1_2; }ATOM_ANALOG_TV_INFO_V1_2;
typedef struct _ATOM_DPCD_INFO typedef struct _ATOM_DPCD_INFO
......
...@@ -2975,7 +2975,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track) ...@@ -2975,7 +2975,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
for (i = 0; i < track->num_cb; i++) { for (i = 0; i < track->num_cb; i++) {
if (track->cb[i].robj == NULL) { if (track->cb[i].robj == NULL) {
if (!(track->fastfill || track->color_channel_mask || if (!(track->zb_cb_clear || track->color_channel_mask ||
track->blend_read_enable)) { track->blend_read_enable)) {
continue; continue;
} }
......
...@@ -75,7 +75,7 @@ struct r100_cs_track { ...@@ -75,7 +75,7 @@ struct r100_cs_track {
struct r100_cs_track_texture textures[R300_TRACK_MAX_TEXTURE]; struct r100_cs_track_texture textures[R300_TRACK_MAX_TEXTURE];
bool z_enabled; bool z_enabled;
bool separate_cube; bool separate_cube;
bool fastfill; bool zb_cb_clear;
bool blend_read_enable; bool blend_read_enable;
}; };
......
...@@ -1044,7 +1044,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p, ...@@ -1044,7 +1044,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
break; break;
case 0x4d1c: case 0x4d1c:
/* ZB_BW_CNTL */ /* ZB_BW_CNTL */
track->fastfill = !!(idx_value & (1 << 2)); track->zb_cb_clear = !!(idx_value & (1 << 5));
break; break;
case 0x4e04: case 0x4e04:
/* RB3D_BLENDCNTL */ /* RB3D_BLENDCNTL */
......
...@@ -134,13 +134,11 @@ int radeon_agp_init(struct radeon_device *rdev) ...@@ -134,13 +134,11 @@ int radeon_agp_init(struct radeon_device *rdev)
int ret; int ret;
/* Acquire AGP. */ /* Acquire AGP. */
if (!rdev->ddev->agp->acquired) {
ret = drm_agp_acquire(rdev->ddev); ret = drm_agp_acquire(rdev->ddev);
if (ret) { if (ret) {
DRM_ERROR("Unable to acquire AGP: %d\n", ret); DRM_ERROR("Unable to acquire AGP: %d\n", ret);
return ret; return ret;
} }
}
ret = drm_agp_info(rdev->ddev, &info); ret = drm_agp_info(rdev->ddev, &info);
if (ret) { if (ret) {
......
...@@ -1264,7 +1264,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, ...@@ -1264,7 +1264,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
switch (crev) { switch (crev) {
case 1: case 1:
tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
if (index > MAX_SUPPORTED_TV_TIMING) if (index >= MAX_SUPPORTED_TV_TIMING)
return false; return false;
mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total);
...@@ -1302,7 +1302,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, ...@@ -1302,7 +1302,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
break; break;
case 2: case 2:
tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset);
if (index > MAX_SUPPORTED_TV_TIMING_V1_2) if (index >= MAX_SUPPORTED_TV_TIMING_V1_2)
return false; return false;
dtd_timings = &tv_info_v1_2->aModeTimings[index]; dtd_timings = &tv_info_v1_2->aModeTimings[index];
......
...@@ -1316,6 +1316,8 @@ radeon_add_legacy_connector(struct drm_device *dev, ...@@ -1316,6 +1316,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
if (!radeon_connector->ddc_bus) if (!radeon_connector->ddc_bus)
goto failed; goto failed;
}
if (connector_type == DRM_MODE_CONNECTOR_DVII) {
radeon_connector->dac_load_detect = true; radeon_connector->dac_load_detect = true;
drm_connector_attach_property(&radeon_connector->base, drm_connector_attach_property(&radeon_connector->base,
rdev->mode_info.load_detect_property, rdev->mode_info.load_detect_property,
......
...@@ -254,6 +254,53 @@ radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder) ...@@ -254,6 +254,53 @@ radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder)
return dig_connector; return dig_connector;
} }
void radeon_panel_mode_fixup(struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode)
{
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
struct drm_device *dev = encoder->dev;
struct radeon_device *rdev = dev->dev_private;
struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
unsigned hblank = native_mode->htotal - native_mode->hdisplay;
unsigned vblank = native_mode->vtotal - native_mode->vdisplay;
unsigned hover = native_mode->hsync_start - native_mode->hdisplay;
unsigned vover = native_mode->vsync_start - native_mode->vdisplay;
unsigned hsync_width = native_mode->hsync_end - native_mode->hsync_start;
unsigned vsync_width = native_mode->vsync_end - native_mode->vsync_start;
adjusted_mode->clock = native_mode->clock;
adjusted_mode->flags = native_mode->flags;
if (ASIC_IS_AVIVO(rdev)) {
adjusted_mode->hdisplay = native_mode->hdisplay;
adjusted_mode->vdisplay = native_mode->vdisplay;
}
adjusted_mode->htotal = native_mode->hdisplay + hblank;
adjusted_mode->hsync_start = native_mode->hdisplay + hover;
adjusted_mode->hsync_end = adjusted_mode->hsync_start + hsync_width;
adjusted_mode->vtotal = native_mode->vdisplay + vblank;
adjusted_mode->vsync_start = native_mode->vdisplay + vover;
adjusted_mode->vsync_end = adjusted_mode->vsync_start + vsync_width;
drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
if (ASIC_IS_AVIVO(rdev)) {
adjusted_mode->crtc_hdisplay = native_mode->hdisplay;
adjusted_mode->crtc_vdisplay = native_mode->vdisplay;
}
adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + hblank;
adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + hover;
adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + hsync_width;
adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + vblank;
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + vover;
adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + vsync_width;
}
static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
struct drm_display_mode *mode, struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
...@@ -275,18 +322,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, ...@@ -275,18 +322,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2; adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2;
/* get the native mode for LVDS */ /* get the native mode for LVDS */
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) { if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
struct drm_display_mode *native_mode = &radeon_encoder->native_mode; radeon_panel_mode_fixup(encoder, adjusted_mode);
int mode_id = adjusted_mode->base.id;
*adjusted_mode = *native_mode;
if (!ASIC_IS_AVIVO(rdev)) {
adjusted_mode->hdisplay = mode->hdisplay;
adjusted_mode->vdisplay = mode->vdisplay;
adjusted_mode->crtc_hdisplay = mode->hdisplay;
adjusted_mode->crtc_vdisplay = mode->vdisplay;
}
adjusted_mode->base.id = mode_id;
}
/* get the native mode for TV */ /* get the native mode for TV */
if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) { if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {
......
...@@ -228,16 +228,8 @@ static bool radeon_legacy_mode_fixup(struct drm_encoder *encoder, ...@@ -228,16 +228,8 @@ static bool radeon_legacy_mode_fixup(struct drm_encoder *encoder,
drm_mode_set_crtcinfo(adjusted_mode, 0); drm_mode_set_crtcinfo(adjusted_mode, 0);
/* get the native mode for LVDS */ /* get the native mode for LVDS */
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) { if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
struct drm_display_mode *native_mode = &radeon_encoder->native_mode; radeon_panel_mode_fixup(encoder, adjusted_mode);
int mode_id = adjusted_mode->base.id;
*adjusted_mode = *native_mode;
adjusted_mode->hdisplay = mode->hdisplay;
adjusted_mode->vdisplay = mode->vdisplay;
adjusted_mode->crtc_hdisplay = mode->hdisplay;
adjusted_mode->crtc_vdisplay = mode->vdisplay;
adjusted_mode->base.id = mode_id;
}
return true; return true;
} }
......
...@@ -558,6 +558,8 @@ extern int radeon_static_clocks_init(struct drm_device *dev); ...@@ -558,6 +558,8 @@ extern int radeon_static_clocks_init(struct drm_device *dev);
bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc, bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
struct drm_display_mode *mode, struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode); struct drm_display_mode *adjusted_mode);
void radeon_panel_mode_fixup(struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode);
void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc); void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc);
/* legacy tv */ /* legacy tv */
......
...@@ -75,7 +75,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -75,7 +75,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (fx->lock > VIA_NR_XVMC_LOCKS) if (fx->lock >= VIA_NR_XVMC_LOCKS)
return -EFAULT; return -EFAULT;
lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock); lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock);
......
...@@ -276,8 +276,10 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, ...@@ -276,8 +276,10 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
mutex_lock(&vgasr_mutex); mutex_lock(&vgasr_mutex);
if (!vgasr_priv.active) if (!vgasr_priv.active) {
return -EINVAL; cnt = -EINVAL;
goto out;
}
/* pwr off the device not in use */ /* pwr off the device not in use */
if (strncmp(usercmd, "OFF", 3) == 0) { if (strncmp(usercmd, "OFF", 3) == 0) {
......
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