Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/anholt/drm-intel

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/anholt/drm-intel:
drm/i915: Add support for VGA load detection (pre-945).
drm/i915: Use an I2C algo to do the flip to SDVO DDC bus.
drm/i915: Determine type before initialising connector
drm/i915: Return SDVO LVDS VBT mode if no EDID modes are detected.
drm/i915: Fetch SDVO LVDS mode lines from VBT, then reserve them
i915: support 8xx desktop cursors
drm/i915: allocate large pointer arrays with vmalloc

+433 -90
+2 -1
drivers/gpu/drm/i915/i915_drv.h
··· 180 180 int backlight_duty_cycle; /* restore backlight to this value */ 181 181 bool panel_wants_dither; 182 182 struct drm_display_mode *panel_fixed_mode; 183 - struct drm_display_mode *vbt_mode; /* if any */ 183 + struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */ 184 + struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */ 184 185 185 186 /* Feature bits from the VBIOS */ 186 187 unsigned int int_tv_support:1;
+17 -25
drivers/gpu/drm/i915/i915_gem.c
··· 349 349 last_data_page = (data_ptr + args->size - 1) / PAGE_SIZE; 350 350 num_pages = last_data_page - first_data_page + 1; 351 351 352 - user_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL); 352 + user_pages = drm_calloc_large(num_pages, sizeof(struct page *)); 353 353 if (user_pages == NULL) 354 354 return -ENOMEM; 355 355 ··· 429 429 SetPageDirty(user_pages[i]); 430 430 page_cache_release(user_pages[i]); 431 431 } 432 - kfree(user_pages); 432 + drm_free_large(user_pages); 433 433 434 434 return ret; 435 435 } ··· 649 649 last_data_page = (data_ptr + args->size - 1) / PAGE_SIZE; 650 650 num_pages = last_data_page - first_data_page + 1; 651 651 652 - user_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL); 652 + user_pages = drm_calloc_large(num_pages, sizeof(struct page *)); 653 653 if (user_pages == NULL) 654 654 return -ENOMEM; 655 655 ··· 719 719 out_unpin_pages: 720 720 for (i = 0; i < pinned_pages; i++) 721 721 page_cache_release(user_pages[i]); 722 - kfree(user_pages); 722 + drm_free_large(user_pages); 723 723 724 724 return ret; 725 725 } ··· 824 824 last_data_page = (data_ptr + args->size - 1) / PAGE_SIZE; 825 825 num_pages = last_data_page - first_data_page + 1; 826 826 827 - user_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL); 827 + user_pages = drm_calloc_large(num_pages, sizeof(struct page *)); 828 828 if (user_pages == NULL) 829 829 return -ENOMEM; 830 830 ··· 902 902 fail_put_user_pages: 903 903 for (i = 0; i < pinned_pages; i++) 904 904 page_cache_release(user_pages[i]); 905 - kfree(user_pages); 905 + drm_free_large(user_pages); 906 906 907 907 return ret; 908 908 } ··· 1145 1145 mutex_unlock(&dev->struct_mutex); 1146 1146 return VM_FAULT_SIGBUS; 1147 1147 } 1148 - list_add(&obj_priv->list, &dev_priv->mm.inactive_list); 1148 + list_add_tail(&obj_priv->list, &dev_priv->mm.inactive_list); 1149 1149 } 1150 1150 1151 1151 /* Need a new fence register? */ ··· 1375 1375 mutex_unlock(&dev->struct_mutex); 1376 1376 return ret; 1377 1377 } 1378 - list_add(&obj_priv->list, &dev_priv->mm.inactive_list); 1378 + list_add_tail(&obj_priv->list, &dev_priv->mm.inactive_list); 1379 1379 } 1380 1380 1381 1381 drm_gem_object_unreference(obj); ··· 1408 1408 } 1409 1409 obj_priv->dirty = 0; 1410 1410 1411 - drm_free(obj_priv->pages, 1412 - page_count * sizeof(struct page *), 1413 - DRM_MEM_DRIVER); 1411 + drm_free_large(obj_priv->pages); 1414 1412 obj_priv->pages = NULL; 1415 1413 } 1416 1414 ··· 2022 2024 */ 2023 2025 page_count = obj->size / PAGE_SIZE; 2024 2026 BUG_ON(obj_priv->pages != NULL); 2025 - obj_priv->pages = drm_calloc(page_count, sizeof(struct page *), 2026 - DRM_MEM_DRIVER); 2027 + obj_priv->pages = drm_calloc_large(page_count, sizeof(struct page *)); 2027 2028 if (obj_priv->pages == NULL) { 2028 2029 DRM_ERROR("Faled to allocate page list\n"); 2029 2030 obj_priv->pages_refcount--; ··· 3108 3111 reloc_count += exec_list[i].relocation_count; 3109 3112 } 3110 3113 3111 - *relocs = drm_calloc(reloc_count, sizeof(**relocs), DRM_MEM_DRIVER); 3114 + *relocs = drm_calloc_large(reloc_count, sizeof(**relocs)); 3112 3115 if (*relocs == NULL) 3113 3116 return -ENOMEM; 3114 3117 ··· 3122 3125 exec_list[i].relocation_count * 3123 3126 sizeof(**relocs)); 3124 3127 if (ret != 0) { 3125 - drm_free(*relocs, reloc_count * sizeof(**relocs), 3126 - DRM_MEM_DRIVER); 3128 + drm_free_large(*relocs); 3127 3129 *relocs = NULL; 3128 3130 return -EFAULT; 3129 3131 } ··· 3161 3165 } 3162 3166 3163 3167 err: 3164 - drm_free(relocs, reloc_count * sizeof(*relocs), DRM_MEM_DRIVER); 3168 + drm_free_large(relocs); 3165 3169 3166 3170 return ret; 3167 3171 } ··· 3194 3198 return -EINVAL; 3195 3199 } 3196 3200 /* Copy in the exec list from userland */ 3197 - exec_list = drm_calloc(sizeof(*exec_list), args->buffer_count, 3198 - DRM_MEM_DRIVER); 3199 - object_list = drm_calloc(sizeof(*object_list), args->buffer_count, 3200 - DRM_MEM_DRIVER); 3201 + exec_list = drm_calloc_large(sizeof(*exec_list), args->buffer_count); 3202 + object_list = drm_calloc_large(sizeof(*object_list), args->buffer_count); 3201 3203 if (exec_list == NULL || object_list == NULL) { 3202 3204 DRM_ERROR("Failed to allocate exec or object list " 3203 3205 "for %d buffers\n", ··· 3456 3462 } 3457 3463 3458 3464 pre_mutex_err: 3459 - drm_free(object_list, sizeof(*object_list) * args->buffer_count, 3460 - DRM_MEM_DRIVER); 3461 - drm_free(exec_list, sizeof(*exec_list) * args->buffer_count, 3462 - DRM_MEM_DRIVER); 3465 + drm_free_large(object_list); 3466 + drm_free_large(exec_list); 3463 3467 drm_free(cliprects, sizeof(*cliprects) * args->num_cliprects, 3464 3468 DRM_MEM_DRIVER); 3465 3469
+17
drivers/gpu/drm/i915/i915_reg.h
··· 1410 1410 1411 1411 /* Cursor A & B regs */ 1412 1412 #define CURACNTR 0x70080 1413 + /* Old style CUR*CNTR flags (desktop 8xx) */ 1414 + #define CURSOR_ENABLE 0x80000000 1415 + #define CURSOR_GAMMA_ENABLE 0x40000000 1416 + #define CURSOR_STRIDE_MASK 0x30000000 1417 + #define CURSOR_FORMAT_SHIFT 24 1418 + #define CURSOR_FORMAT_MASK (0x07 << CURSOR_FORMAT_SHIFT) 1419 + #define CURSOR_FORMAT_2C (0x00 << CURSOR_FORMAT_SHIFT) 1420 + #define CURSOR_FORMAT_3C (0x01 << CURSOR_FORMAT_SHIFT) 1421 + #define CURSOR_FORMAT_4C (0x02 << CURSOR_FORMAT_SHIFT) 1422 + #define CURSOR_FORMAT_ARGB (0x04 << CURSOR_FORMAT_SHIFT) 1423 + #define CURSOR_FORMAT_XRGB (0x05 << CURSOR_FORMAT_SHIFT) 1424 + /* New style CUR*CNTR flags */ 1425 + #define CURSOR_MODE 0x27 1413 1426 #define CURSOR_MODE_DISABLE 0x00 1414 1427 #define CURSOR_MODE_64_32B_AX 0x07 1415 1428 #define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX) 1429 + #define MCURSOR_PIPE_SELECT (1 << 28) 1430 + #define MCURSOR_PIPE_A 0x00 1431 + #define MCURSOR_PIPE_B (1 << 28) 1416 1432 #define MCURSOR_GAMMA_ENABLE (1 << 26) 1417 1433 #define CURABASE 0x70084 1418 1434 #define CURAPOS 0x70088 ··· 1436 1420 #define CURSOR_POS_SIGN 0x8000 1437 1421 #define CURSOR_X_SHIFT 0 1438 1422 #define CURSOR_Y_SHIFT 16 1423 + #define CURSIZE 0x700a0 1439 1424 #define CURBCNTR 0x700c0 1440 1425 #define CURBBASE 0x700c4 1441 1426 #define CURBPOS 0x700c8
+73 -31
drivers/gpu/drm/i915/intel_bios.c
··· 57 57 return NULL; 58 58 } 59 59 60 - /* Try to find panel data */ 61 60 static void 62 - parse_panel_data(struct drm_i915_private *dev_priv, struct bdb_header *bdb) 61 + fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode, 62 + struct lvds_dvo_timing *dvo_timing) 63 + { 64 + panel_fixed_mode->hdisplay = (dvo_timing->hactive_hi << 8) | 65 + dvo_timing->hactive_lo; 66 + panel_fixed_mode->hsync_start = panel_fixed_mode->hdisplay + 67 + ((dvo_timing->hsync_off_hi << 8) | dvo_timing->hsync_off_lo); 68 + panel_fixed_mode->hsync_end = panel_fixed_mode->hsync_start + 69 + dvo_timing->hsync_pulse_width; 70 + panel_fixed_mode->htotal = panel_fixed_mode->hdisplay + 71 + ((dvo_timing->hblank_hi << 8) | dvo_timing->hblank_lo); 72 + 73 + panel_fixed_mode->vdisplay = (dvo_timing->vactive_hi << 8) | 74 + dvo_timing->vactive_lo; 75 + panel_fixed_mode->vsync_start = panel_fixed_mode->vdisplay + 76 + dvo_timing->vsync_off; 77 + panel_fixed_mode->vsync_end = panel_fixed_mode->vsync_start + 78 + dvo_timing->vsync_pulse_width; 79 + panel_fixed_mode->vtotal = panel_fixed_mode->vdisplay + 80 + ((dvo_timing->vblank_hi << 8) | dvo_timing->vblank_lo); 81 + panel_fixed_mode->clock = dvo_timing->clock * 10; 82 + panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED; 83 + 84 + /* Some VBTs have bogus h/vtotal values */ 85 + if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal) 86 + panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1; 87 + if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal) 88 + panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1; 89 + 90 + drm_mode_set_name(panel_fixed_mode); 91 + } 92 + 93 + /* Try to find integrated panel data */ 94 + static void 95 + parse_lfp_panel_data(struct drm_i915_private *dev_priv, 96 + struct bdb_header *bdb) 63 97 { 64 98 struct bdb_lvds_options *lvds_options; 65 99 struct bdb_lvds_lfp_data *lvds_lfp_data; ··· 125 91 panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode), 126 92 DRM_MEM_DRIVER); 127 93 128 - panel_fixed_mode->hdisplay = (dvo_timing->hactive_hi << 8) | 129 - dvo_timing->hactive_lo; 130 - panel_fixed_mode->hsync_start = panel_fixed_mode->hdisplay + 131 - ((dvo_timing->hsync_off_hi << 8) | dvo_timing->hsync_off_lo); 132 - panel_fixed_mode->hsync_end = panel_fixed_mode->hsync_start + 133 - dvo_timing->hsync_pulse_width; 134 - panel_fixed_mode->htotal = panel_fixed_mode->hdisplay + 135 - ((dvo_timing->hblank_hi << 8) | dvo_timing->hblank_lo); 94 + fill_detail_timing_data(panel_fixed_mode, dvo_timing); 136 95 137 - panel_fixed_mode->vdisplay = (dvo_timing->vactive_hi << 8) | 138 - dvo_timing->vactive_lo; 139 - panel_fixed_mode->vsync_start = panel_fixed_mode->vdisplay + 140 - dvo_timing->vsync_off; 141 - panel_fixed_mode->vsync_end = panel_fixed_mode->vsync_start + 142 - dvo_timing->vsync_pulse_width; 143 - panel_fixed_mode->vtotal = panel_fixed_mode->vdisplay + 144 - ((dvo_timing->vblank_hi << 8) | dvo_timing->vblank_lo); 145 - panel_fixed_mode->clock = dvo_timing->clock * 10; 146 - panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED; 147 - 148 - /* Some VBTs have bogus h/vtotal values */ 149 - if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal) 150 - panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1; 151 - if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal) 152 - panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1; 153 - 154 - drm_mode_set_name(panel_fixed_mode); 155 - 156 - dev_priv->vbt_mode = panel_fixed_mode; 96 + dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode; 157 97 158 98 DRM_DEBUG("Found panel mode in BIOS VBT tables:\n"); 159 99 drm_mode_debug_printmodeline(panel_fixed_mode); 100 + 101 + return; 102 + } 103 + 104 + /* Try to find sdvo panel data */ 105 + static void 106 + parse_sdvo_panel_data(struct drm_i915_private *dev_priv, 107 + struct bdb_header *bdb) 108 + { 109 + struct bdb_sdvo_lvds_options *sdvo_lvds_options; 110 + struct lvds_dvo_timing *dvo_timing; 111 + struct drm_display_mode *panel_fixed_mode; 112 + 113 + dev_priv->sdvo_lvds_vbt_mode = NULL; 114 + 115 + sdvo_lvds_options = find_section(bdb, BDB_SDVO_LVDS_OPTIONS); 116 + if (!sdvo_lvds_options) 117 + return; 118 + 119 + dvo_timing = find_section(bdb, BDB_SDVO_PANEL_DTDS); 120 + if (!dvo_timing) 121 + return; 122 + 123 + panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode), 124 + DRM_MEM_DRIVER); 125 + 126 + if (!panel_fixed_mode) 127 + return; 128 + 129 + fill_detail_timing_data(panel_fixed_mode, 130 + dvo_timing + sdvo_lvds_options->panel_type); 131 + 132 + dev_priv->sdvo_lvds_vbt_mode = panel_fixed_mode; 160 133 161 134 return; 162 135 } ··· 240 199 241 200 /* Grab useful general definitions */ 242 201 parse_general_features(dev_priv, bdb); 243 - parse_panel_data(dev_priv, bdb); 202 + parse_lfp_panel_data(dev_priv, bdb); 203 + parse_sdvo_panel_data(dev_priv, bdb); 244 204 245 205 pci_unmap_rom(pdev, bios); 246 206
+17
drivers/gpu/drm/i915/intel_bios.h
··· 279 279 struct vch_panel_data panels[16]; 280 280 } __attribute__((packed)); 281 281 282 + struct bdb_sdvo_lvds_options { 283 + u8 panel_backlight; 284 + u8 h40_set_panel_type; 285 + u8 panel_type; 286 + u8 ssc_clk_freq; 287 + u16 als_low_trip; 288 + u16 als_high_trip; 289 + u8 sclalarcoeff_tab_row_num; 290 + u8 sclalarcoeff_tab_row_size; 291 + u8 coefficient[8]; 292 + u8 panel_misc_bits_1; 293 + u8 panel_misc_bits_2; 294 + u8 panel_misc_bits_3; 295 + u8 panel_misc_bits_4; 296 + } __attribute__((packed)); 297 + 298 + 282 299 bool intel_init_bios(struct drm_device *dev); 283 300 284 301 /*
+147 -2
drivers/gpu/drm/i915/intel_crt.c
··· 198 198 return intel_ddc_probe(intel_output); 199 199 } 200 200 201 + static enum drm_connector_status 202 + intel_crt_load_detect(struct drm_crtc *crtc, struct intel_output *intel_output) 203 + { 204 + struct drm_encoder *encoder = &intel_output->enc; 205 + struct drm_device *dev = encoder->dev; 206 + struct drm_i915_private *dev_priv = dev->dev_private; 207 + struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 208 + uint32_t pipe = intel_crtc->pipe; 209 + uint32_t save_bclrpat; 210 + uint32_t save_vtotal; 211 + uint32_t vtotal, vactive; 212 + uint32_t vsample; 213 + uint32_t vblank, vblank_start, vblank_end; 214 + uint32_t dsl; 215 + uint32_t bclrpat_reg; 216 + uint32_t vtotal_reg; 217 + uint32_t vblank_reg; 218 + uint32_t vsync_reg; 219 + uint32_t pipeconf_reg; 220 + uint32_t pipe_dsl_reg; 221 + uint8_t st00; 222 + enum drm_connector_status status; 223 + 224 + if (pipe == 0) { 225 + bclrpat_reg = BCLRPAT_A; 226 + vtotal_reg = VTOTAL_A; 227 + vblank_reg = VBLANK_A; 228 + vsync_reg = VSYNC_A; 229 + pipeconf_reg = PIPEACONF; 230 + pipe_dsl_reg = PIPEADSL; 231 + } else { 232 + bclrpat_reg = BCLRPAT_B; 233 + vtotal_reg = VTOTAL_B; 234 + vblank_reg = VBLANK_B; 235 + vsync_reg = VSYNC_B; 236 + pipeconf_reg = PIPEBCONF; 237 + pipe_dsl_reg = PIPEBDSL; 238 + } 239 + 240 + save_bclrpat = I915_READ(bclrpat_reg); 241 + save_vtotal = I915_READ(vtotal_reg); 242 + vblank = I915_READ(vblank_reg); 243 + 244 + vtotal = ((save_vtotal >> 16) & 0xfff) + 1; 245 + vactive = (save_vtotal & 0x7ff) + 1; 246 + 247 + vblank_start = (vblank & 0xfff) + 1; 248 + vblank_end = ((vblank >> 16) & 0xfff) + 1; 249 + 250 + /* Set the border color to purple. */ 251 + I915_WRITE(bclrpat_reg, 0x500050); 252 + 253 + if (IS_I9XX(dev)) { 254 + uint32_t pipeconf = I915_READ(pipeconf_reg); 255 + I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER); 256 + /* Wait for next Vblank to substitue 257 + * border color for Color info */ 258 + intel_wait_for_vblank(dev); 259 + st00 = I915_READ8(VGA_MSR_WRITE); 260 + status = ((st00 & (1 << 4)) != 0) ? 261 + connector_status_connected : 262 + connector_status_disconnected; 263 + 264 + I915_WRITE(pipeconf_reg, pipeconf); 265 + } else { 266 + bool restore_vblank = false; 267 + int count, detect; 268 + 269 + /* 270 + * If there isn't any border, add some. 271 + * Yes, this will flicker 272 + */ 273 + if (vblank_start <= vactive && vblank_end >= vtotal) { 274 + uint32_t vsync = I915_READ(vsync_reg); 275 + uint32_t vsync_start = (vsync & 0xffff) + 1; 276 + 277 + vblank_start = vsync_start; 278 + I915_WRITE(vblank_reg, 279 + (vblank_start - 1) | 280 + ((vblank_end - 1) << 16)); 281 + restore_vblank = true; 282 + } 283 + /* sample in the vertical border, selecting the larger one */ 284 + if (vblank_start - vactive >= vtotal - vblank_end) 285 + vsample = (vblank_start + vactive) >> 1; 286 + else 287 + vsample = (vtotal + vblank_end) >> 1; 288 + 289 + /* 290 + * Wait for the border to be displayed 291 + */ 292 + while (I915_READ(pipe_dsl_reg) >= vactive) 293 + ; 294 + while ((dsl = I915_READ(pipe_dsl_reg)) <= vsample) 295 + ; 296 + /* 297 + * Watch ST00 for an entire scanline 298 + */ 299 + detect = 0; 300 + count = 0; 301 + do { 302 + count++; 303 + /* Read the ST00 VGA status register */ 304 + st00 = I915_READ8(VGA_MSR_WRITE); 305 + if (st00 & (1 << 4)) 306 + detect++; 307 + } while ((I915_READ(pipe_dsl_reg) == dsl)); 308 + 309 + /* restore vblank if necessary */ 310 + if (restore_vblank) 311 + I915_WRITE(vblank_reg, vblank); 312 + /* 313 + * If more than 3/4 of the scanline detected a monitor, 314 + * then it is assumed to be present. This works even on i830, 315 + * where there isn't any way to force the border color across 316 + * the screen 317 + */ 318 + status = detect * 4 > count * 3 ? 319 + connector_status_connected : 320 + connector_status_disconnected; 321 + } 322 + 323 + /* Restore previous settings */ 324 + I915_WRITE(bclrpat_reg, save_bclrpat); 325 + 326 + return status; 327 + } 328 + 201 329 static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) 202 330 { 203 331 struct drm_device *dev = connector->dev; 332 + struct intel_output *intel_output = to_intel_output(connector); 333 + struct drm_encoder *encoder = &intel_output->enc; 334 + struct drm_crtc *crtc; 335 + int dpms_mode; 336 + enum drm_connector_status status; 204 337 205 338 if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) { 206 339 if (intel_crt_detect_hotplug(connector)) ··· 345 212 if (intel_crt_detect_ddc(connector)) 346 213 return connector_status_connected; 347 214 348 - /* TODO use load detect */ 349 - return connector_status_unknown; 215 + /* for pre-945g platforms use load detect */ 216 + if (encoder->crtc && encoder->crtc->enabled) { 217 + status = intel_crt_load_detect(encoder->crtc, intel_output); 218 + } else { 219 + crtc = intel_get_load_detect_pipe(intel_output, 220 + NULL, &dpms_mode); 221 + if (crtc) { 222 + status = intel_crt_load_detect(crtc, intel_output); 223 + intel_release_load_detect_pipe(intel_output, dpms_mode); 224 + } else 225 + status = connector_status_unknown; 226 + } 227 + 228 + return status; 350 229 } 351 230 352 231 static void intel_crt_destroy(struct drm_connector *connector)
+20 -6
drivers/gpu/drm/i915/intel_display.c
··· 1357 1357 int pipe = intel_crtc->pipe; 1358 1358 uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR; 1359 1359 uint32_t base = (pipe == 0) ? CURABASE : CURBBASE; 1360 - uint32_t temp; 1360 + uint32_t temp = I915_READ(control); 1361 1361 size_t addr; 1362 1362 int ret; 1363 1363 ··· 1366 1366 /* if we want to turn off the cursor ignore width and height */ 1367 1367 if (!handle) { 1368 1368 DRM_DEBUG("cursor off\n"); 1369 - temp = CURSOR_MODE_DISABLE; 1369 + if (IS_MOBILE(dev) || IS_I9XX(dev)) { 1370 + temp &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); 1371 + temp |= CURSOR_MODE_DISABLE; 1372 + } else { 1373 + temp &= ~(CURSOR_ENABLE | CURSOR_GAMMA_ENABLE); 1374 + } 1370 1375 addr = 0; 1371 1376 bo = NULL; 1372 1377 mutex_lock(&dev->struct_mutex); ··· 1414 1409 addr = obj_priv->phys_obj->handle->busaddr; 1415 1410 } 1416 1411 1417 - temp = 0; 1418 - /* set the pipe for the cursor */ 1419 - temp |= (pipe << 28); 1420 - temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; 1412 + if (!IS_I9XX(dev)) 1413 + I915_WRITE(CURSIZE, (height << 12) | width); 1414 + 1415 + /* Hooray for CUR*CNTR differences */ 1416 + if (IS_MOBILE(dev) || IS_I9XX(dev)) { 1417 + temp &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); 1418 + temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; 1419 + temp |= (pipe << 28); /* Connect to correct pipe */ 1420 + } else { 1421 + temp &= ~(CURSOR_FORMAT_MASK); 1422 + temp |= CURSOR_ENABLE; 1423 + temp |= CURSOR_FORMAT_ARGB | CURSOR_GAMMA_ENABLE; 1424 + } 1421 1425 1422 1426 finish: 1423 1427 I915_WRITE(control, temp);
+2 -2
drivers/gpu/drm/i915/intel_lvds.c
··· 511 511 } 512 512 513 513 /* Failed to get EDID, what about VBT? */ 514 - if (dev_priv->vbt_mode) { 514 + if (dev_priv->lfp_lvds_vbt_mode) { 515 515 mutex_lock(&dev->mode_config.mutex); 516 516 dev_priv->panel_fixed_mode = 517 - drm_mode_duplicate(dev, dev_priv->vbt_mode); 517 + drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); 518 518 mutex_unlock(&dev->mode_config.mutex); 519 519 if (dev_priv->panel_fixed_mode) { 520 520 dev_priv->panel_fixed_mode->type |=
+114 -23
drivers/gpu/drm/i915/intel_sdvo.c
··· 69 69 * This is set if we treat the device as HDMI, instead of DVI. 70 70 */ 71 71 bool is_hdmi; 72 + /** 73 + * This is set if we detect output of sdvo device as LVDS. 74 + */ 75 + bool is_lvds; 72 76 73 77 /** 74 78 * Returned SDTV resolutions allowed for the current format, if the ··· 1402 1398 static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) 1403 1399 { 1404 1400 struct intel_output *intel_output = to_intel_output(connector); 1405 - struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1406 1401 1407 1402 /* set the bus switch and get the modes */ 1408 - intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 1409 1403 intel_ddc_get_modes(intel_output); 1410 1404 1411 1405 #if 0 ··· 1545 1543 } 1546 1544 } 1547 1545 1546 + static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) 1547 + { 1548 + struct intel_output *intel_output = to_intel_output(connector); 1549 + struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1550 + struct drm_i915_private *dev_priv = connector->dev->dev_private; 1551 + 1552 + /* 1553 + * Attempt to get the mode list from DDC. 1554 + * Assume that the preferred modes are 1555 + * arranged in priority order. 1556 + */ 1557 + /* set the bus switch and get the modes */ 1558 + intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 1559 + intel_ddc_get_modes(intel_output); 1560 + if (list_empty(&connector->probed_modes) == false) 1561 + return; 1562 + 1563 + /* Fetch modes from VBT */ 1564 + if (dev_priv->sdvo_lvds_vbt_mode != NULL) { 1565 + struct drm_display_mode *newmode; 1566 + newmode = drm_mode_duplicate(connector->dev, 1567 + dev_priv->sdvo_lvds_vbt_mode); 1568 + if (newmode != NULL) { 1569 + /* Guarantee the mode is preferred */ 1570 + newmode->type = (DRM_MODE_TYPE_PREFERRED | 1571 + DRM_MODE_TYPE_DRIVER); 1572 + drm_mode_probed_add(connector, newmode); 1573 + } 1574 + } 1575 + } 1576 + 1548 1577 static int intel_sdvo_get_modes(struct drm_connector *connector) 1549 1578 { 1550 1579 struct intel_output *output = to_intel_output(connector); ··· 1583 1550 1584 1551 if (sdvo_priv->is_tv) 1585 1552 intel_sdvo_get_tv_modes(connector); 1553 + else if (sdvo_priv->is_lvds == true) 1554 + intel_sdvo_get_lvds_modes(connector); 1586 1555 else 1587 1556 intel_sdvo_get_ddc_modes(connector); 1588 1557 ··· 1599 1564 1600 1565 if (intel_output->i2c_bus) 1601 1566 intel_i2c_destroy(intel_output->i2c_bus); 1567 + if (intel_output->ddc_bus) 1568 + intel_i2c_destroy(intel_output->ddc_bus); 1569 + 1602 1570 drm_sysfs_connector_remove(connector); 1603 1571 drm_connector_cleanup(connector); 1604 1572 kfree(intel_output); ··· 1698 1660 return true; 1699 1661 } 1700 1662 1663 + static struct intel_output * 1664 + intel_sdvo_chan_to_intel_output(struct intel_i2c_chan *chan) 1665 + { 1666 + struct drm_device *dev = chan->drm_dev; 1667 + struct drm_connector *connector; 1668 + struct intel_output *intel_output = NULL; 1669 + 1670 + list_for_each_entry(connector, 1671 + &dev->mode_config.connector_list, head) { 1672 + if (to_intel_output(connector)->ddc_bus == chan) { 1673 + intel_output = to_intel_output(connector); 1674 + break; 1675 + } 1676 + } 1677 + return intel_output; 1678 + } 1679 + 1680 + static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap, 1681 + struct i2c_msg msgs[], int num) 1682 + { 1683 + struct intel_output *intel_output; 1684 + struct intel_sdvo_priv *sdvo_priv; 1685 + struct i2c_algo_bit_data *algo_data; 1686 + struct i2c_algorithm *algo; 1687 + 1688 + algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data; 1689 + intel_output = 1690 + intel_sdvo_chan_to_intel_output( 1691 + (struct intel_i2c_chan *)(algo_data->data)); 1692 + if (intel_output == NULL) 1693 + return -EINVAL; 1694 + 1695 + sdvo_priv = intel_output->dev_priv; 1696 + algo = (struct i2c_algorithm *)intel_output->i2c_bus->adapter.algo; 1697 + 1698 + intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 1699 + return algo->master_xfer(i2c_adap, msgs, num); 1700 + } 1701 + 1702 + static struct i2c_algorithm intel_sdvo_i2c_bit_algo = { 1703 + .master_xfer = intel_sdvo_master_xfer, 1704 + }; 1705 + 1701 1706 bool intel_sdvo_init(struct drm_device *dev, int output_device) 1702 1707 { 1703 1708 struct drm_connector *connector; 1704 1709 struct intel_output *intel_output; 1705 1710 struct intel_sdvo_priv *sdvo_priv; 1706 1711 struct intel_i2c_chan *i2cbus = NULL; 1712 + struct intel_i2c_chan *ddcbus = NULL; 1707 1713 int connector_type; 1708 1714 u8 ch[0x40]; 1709 1715 int i; ··· 1758 1676 return false; 1759 1677 } 1760 1678 1761 - connector = &intel_output->base; 1762 - 1763 - drm_connector_init(dev, connector, &intel_sdvo_connector_funcs, 1764 - DRM_MODE_CONNECTOR_Unknown); 1765 - drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs); 1766 1679 sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); 1767 1680 intel_output->type = INTEL_OUTPUT_SDVO; 1768 - 1769 - connector->interlace_allowed = 0; 1770 - connector->doublescan_allowed = 0; 1771 1681 1772 1682 /* setup the DDC bus. */ 1773 1683 if (output_device == SDVOB) ··· 1768 1694 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); 1769 1695 1770 1696 if (!i2cbus) 1771 - goto err_connector; 1697 + goto err_inteloutput; 1772 1698 1773 1699 sdvo_priv->i2c_bus = i2cbus; 1774 1700 ··· 1784 1710 intel_output->i2c_bus = i2cbus; 1785 1711 intel_output->dev_priv = sdvo_priv; 1786 1712 1787 - 1788 1713 /* Read the regs to test if we can talk to the device */ 1789 1714 for (i = 0; i < 0x40; i++) { 1790 1715 if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) { ··· 1793 1720 } 1794 1721 } 1795 1722 1723 + /* setup the DDC bus. */ 1724 + if (output_device == SDVOB) 1725 + ddcbus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); 1726 + else 1727 + ddcbus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); 1728 + 1729 + if (ddcbus == NULL) 1730 + goto err_i2c; 1731 + 1732 + intel_sdvo_i2c_bit_algo.functionality = 1733 + intel_output->i2c_bus->adapter.algo->functionality; 1734 + ddcbus->adapter.algo = &intel_sdvo_i2c_bit_algo; 1735 + intel_output->ddc_bus = ddcbus; 1736 + 1737 + /* In defaut case sdvo lvds is false */ 1738 + sdvo_priv->is_lvds = false; 1796 1739 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); 1797 1740 1798 1741 if (sdvo_priv->caps.output_flags & ··· 1818 1729 else 1819 1730 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1; 1820 1731 1821 - connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1822 1732 encoder_type = DRM_MODE_ENCODER_TMDS; 1823 1733 connector_type = DRM_MODE_CONNECTOR_DVID; 1824 1734 ··· 1835 1747 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0) 1836 1748 { 1837 1749 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0; 1838 - connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1839 1750 encoder_type = DRM_MODE_ENCODER_TVDAC; 1840 1751 connector_type = DRM_MODE_CONNECTOR_SVIDEO; 1841 1752 sdvo_priv->is_tv = true; ··· 1843 1756 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0) 1844 1757 { 1845 1758 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0; 1846 - connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1847 1759 encoder_type = DRM_MODE_ENCODER_DAC; 1848 1760 connector_type = DRM_MODE_CONNECTOR_VGA; 1849 1761 } 1850 1762 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) 1851 1763 { 1852 1764 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1; 1853 - connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1854 1765 encoder_type = DRM_MODE_ENCODER_DAC; 1855 1766 connector_type = DRM_MODE_CONNECTOR_VGA; 1856 1767 } 1857 1768 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0) 1858 1769 { 1859 1770 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0; 1860 - connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1861 1771 encoder_type = DRM_MODE_ENCODER_LVDS; 1862 1772 connector_type = DRM_MODE_CONNECTOR_LVDS; 1773 + sdvo_priv->is_lvds = true; 1863 1774 } 1864 1775 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1) 1865 1776 { 1866 1777 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1; 1867 - connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1868 1778 encoder_type = DRM_MODE_ENCODER_LVDS; 1869 1779 connector_type = DRM_MODE_CONNECTOR_LVDS; 1780 + sdvo_priv->is_lvds = true; 1870 1781 } 1871 1782 else 1872 1783 { ··· 1880 1795 goto err_i2c; 1881 1796 } 1882 1797 1798 + connector = &intel_output->base; 1799 + drm_connector_init(dev, connector, &intel_sdvo_connector_funcs, 1800 + connector_type); 1801 + drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs); 1802 + connector->interlace_allowed = 0; 1803 + connector->doublescan_allowed = 0; 1804 + connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1805 + 1883 1806 drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type); 1884 1807 drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs); 1885 - connector->connector_type = connector_type; 1886 1808 1887 1809 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1888 1810 drm_sysfs_connector_add(connector); ··· 1921 1829 sdvo_priv->caps.output_flags & 1922 1830 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); 1923 1831 1924 - intel_output->ddc_bus = i2cbus; 1925 - 1926 1832 return true; 1927 1833 1928 1834 err_i2c: 1835 + if (ddcbus != NULL) 1836 + intel_i2c_destroy(intel_output->ddc_bus); 1929 1837 intel_i2c_destroy(intel_output->i2c_bus); 1930 - err_connector: 1931 - drm_connector_cleanup(connector); 1838 + err_inteloutput: 1932 1839 kfree(intel_output); 1933 1840 1934 1841 return false;
+24
include/drm/drmP.h
··· 1519 1519 { 1520 1520 return kcalloc(nmemb, size, GFP_KERNEL); 1521 1521 } 1522 + 1523 + static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) 1524 + { 1525 + u8 *addr; 1526 + 1527 + if (size <= PAGE_SIZE) 1528 + return kcalloc(nmemb, size, GFP_KERNEL); 1529 + 1530 + addr = vmalloc(nmemb * size); 1531 + if (!addr) 1532 + return NULL; 1533 + 1534 + memset(addr, 0, nmemb * size); 1535 + 1536 + return addr; 1537 + } 1538 + 1539 + static __inline void drm_free_large(void *ptr) 1540 + { 1541 + if (!is_vmalloc_addr(ptr)) 1542 + return kfree(ptr); 1543 + 1544 + vfree(ptr); 1545 + } 1522 1546 #else 1523 1547 extern void *drm_alloc(size_t size, int area); 1524 1548 extern void drm_free(void *pt, size_t size, int area);