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

Merge tag 'topic/core-stuff-2014-05-05' of git://anongit.freedesktop.org/drm-intel into drm-next

Update pull request with drm core patches. Mostly some polish for the
primary plane stuff and a pile of patches all over from Thierry. Has
survived a few days in drm-intel-nightly without causing ill.

I've frobbed my scripts a bit to also tag my topic branches so that you
have something stable to pull - I've accidentally pushed a bunch more
patches onto this branch before you've taken the old pull request.

* tag 'topic/core-stuff-2014-05-05' of git://anongit.freedesktop.org/drm-intel:
drm: Make drm_crtc_helper_disable() return void
drm: Fix indentation of closing brace
drm/dp: Fix typo in comment
drm: Fixup flip-work kerneldoc
drm/fb: Fix typos
drm/edid: Cleanup kerneldoc
drm/edid: Drop revision argument for drm_mode_std()
drm: Try to acquire modeset lock on panic or sysrq
drm: remove unused argument from drm_open_helper
drm: Handle ->disable_plane failures correctly
drm: Simplify fb refcounting rules around ->update_plane
drm/crtc-helper: gc usless connector loop in disable_unused_functions
drm/plane_helper: don't disable plane in destroy function
drm/plane-helper: Fix primary plane scaling check
drm: make mode_valid callback optional
drm/edid: Fill PAR in AVI infoframe based on CEA mode list

+153 -183
+3 -3
Documentation/DocBook/drm.tmpl
··· 1895 1895 <para> 1896 1896 The function filters out modes larger than 1897 1897 <parameter>max_width</parameter> and <parameter>max_height</parameter> 1898 - if specified. It then calls the connector 1899 - <methodname>mode_valid</methodname> helper operation for each mode in 1898 + if specified. It then calls the optional connector 1899 + <methodname>mode_valid</methodname> helper operation for each mode in 1900 1900 the probed list to check whether the mode is valid for the connector. 1901 1901 </para> 1902 1902 </listitem> ··· 2257 2257 <para> 2258 2258 Verify whether a mode is valid for the connector. Return MODE_OK for 2259 2259 supported modes and one of the enum drm_mode_status values (MODE_*) 2260 - for unsupported modes. This operation is mandatory. 2260 + for unsupported modes. This operation is optional. 2261 2261 </para> 2262 2262 <para> 2263 2263 As the mode rejection reason is currently not used beside for
-7
drivers/gpu/drm/ast/ast_mode.c
··· 743 743 return 0; 744 744 } 745 745 746 - static int ast_mode_valid(struct drm_connector *connector, 747 - struct drm_display_mode *mode) 748 - { 749 - return MODE_OK; 750 - } 751 - 752 746 static void ast_connector_destroy(struct drm_connector *connector) 753 747 { 754 748 struct ast_connector *ast_connector = to_ast_connector(connector); ··· 759 765 } 760 766 761 767 static const struct drm_connector_helper_funcs ast_connector_helper_funcs = { 762 - .mode_valid = ast_mode_valid, 763 768 .get_modes = ast_get_modes, 764 769 .best_encoder = ast_best_single_encoder, 765 770 };
-7
drivers/gpu/drm/bridge/ptn3460.c
··· 225 225 return num_modes; 226 226 } 227 227 228 - static int ptn3460_mode_valid(struct drm_connector *connector, 229 - struct drm_display_mode *mode) 230 - { 231 - return MODE_OK; 232 - } 233 - 234 228 struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) 235 229 { 236 230 struct ptn3460_bridge *ptn_bridge; ··· 236 242 237 243 struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { 238 244 .get_modes = ptn3460_get_modes, 239 - .mode_valid = ptn3460_mode_valid, 240 245 .best_encoder = ptn3460_best_encoder, 241 246 }; 242 247
-8
drivers/gpu/drm/cirrus/cirrus_mode.c
··· 505 505 return count; 506 506 } 507 507 508 - static int cirrus_vga_mode_valid(struct drm_connector *connector, 509 - struct drm_display_mode *mode) 510 - { 511 - /* Any mode we've added is valid */ 512 - return MODE_OK; 513 - } 514 - 515 508 static struct drm_encoder *cirrus_connector_best_encoder(struct drm_connector 516 509 *connector) 517 510 { ··· 539 546 540 547 struct drm_connector_helper_funcs cirrus_vga_connector_helper_funcs = { 541 548 .get_modes = cirrus_vga_get_modes, 542 - .mode_valid = cirrus_vga_mode_valid, 543 549 .best_encoder = cirrus_connector_best_encoder, 544 550 }; 545 551
+1 -1
drivers/gpu/drm/drm_bufs.c
··· 363 363 list->master = dev->primary->master; 364 364 *maplist = list; 365 365 return 0; 366 - } 366 + } 367 367 368 368 int drm_addmap(struct drm_device * dev, resource_size_t offset, 369 369 unsigned int size, enum drm_map_type type,
+17 -10
drivers/gpu/drm/drm_crtc.c
··· 1145 1145 */ 1146 1146 void drm_plane_force_disable(struct drm_plane *plane) 1147 1147 { 1148 + struct drm_framebuffer *old_fb = plane->fb; 1148 1149 int ret; 1149 1150 1150 - if (!plane->fb) 1151 + if (!old_fb) 1151 1152 return; 1152 1153 1153 1154 ret = plane->funcs->disable_plane(plane); 1154 - if (ret) 1155 + if (ret) { 1155 1156 DRM_ERROR("failed to disable plane with busy fb\n"); 1157 + return; 1158 + } 1156 1159 /* disconnect the plane from the fb and crtc: */ 1157 - __drm_framebuffer_unreference(plane->fb); 1160 + __drm_framebuffer_unreference(old_fb); 1158 1161 plane->fb = NULL; 1159 1162 plane->crtc = NULL; 1160 1163 } ··· 2125 2122 if (!plane_req->fb_id) { 2126 2123 drm_modeset_lock_all(dev); 2127 2124 old_fb = plane->fb; 2128 - plane->funcs->disable_plane(plane); 2129 - plane->crtc = NULL; 2130 - plane->fb = NULL; 2125 + ret = plane->funcs->disable_plane(plane); 2126 + if (!ret) { 2127 + plane->crtc = NULL; 2128 + plane->fb = NULL; 2129 + } else { 2130 + old_fb = NULL; 2131 + } 2131 2132 drm_modeset_unlock_all(dev); 2132 2133 goto out; 2133 2134 } ··· 2200 2193 } 2201 2194 2202 2195 drm_modeset_lock_all(dev); 2196 + old_fb = plane->fb; 2203 2197 ret = plane->funcs->update_plane(plane, crtc, fb, 2204 2198 plane_req->crtc_x, plane_req->crtc_y, 2205 2199 plane_req->crtc_w, plane_req->crtc_h, 2206 2200 plane_req->src_x, plane_req->src_y, 2207 2201 plane_req->src_w, plane_req->src_h); 2208 2202 if (!ret) { 2209 - old_fb = plane->fb; 2210 2203 plane->crtc = crtc; 2211 2204 plane->fb = fb; 2212 2205 fb = NULL; 2206 + } else { 2207 + old_fb = NULL; 2213 2208 } 2214 2209 drm_modeset_unlock_all(dev); 2215 2210 ··· 2254 2245 ret = crtc->funcs->set_config(set); 2255 2246 if (ret == 0) { 2256 2247 crtc->primary->crtc = crtc; 2257 - 2258 - /* crtc->fb must be updated by ->set_config, enforces this. */ 2259 - WARN_ON(fb != crtc->primary->fb); 2248 + crtc->primary->fb = fb; 2260 2249 } 2261 2250 2262 2251 list_for_each_entry(tmp, &crtc->dev->mode_config.crtc_list, head) {
+3 -10
drivers/gpu/drm/drm_crtc_helper.c
··· 140 140 static void __drm_helper_disable_unused_functions(struct drm_device *dev) 141 141 { 142 142 struct drm_encoder *encoder; 143 - struct drm_connector *connector; 144 143 struct drm_crtc *crtc; 145 144 146 145 drm_warn_on_modeset_not_all_locked(dev); 147 - 148 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 149 - if (!connector->encoder) 150 - continue; 151 - } 152 146 153 147 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 154 148 if (!drm_helper_encoder_in_use(encoder)) { ··· 381 387 } 382 388 EXPORT_SYMBOL(drm_crtc_helper_set_mode); 383 389 384 - 385 - static int 390 + static void 386 391 drm_crtc_helper_disable(struct drm_crtc *crtc) 387 392 { 388 393 struct drm_device *dev = crtc->dev; ··· 410 417 } 411 418 412 419 __drm_helper_disable_unused_functions(dev); 413 - return 0; 414 420 } 415 421 416 422 /** ··· 460 468 (int)set->num_connectors, set->x, set->y); 461 469 } else { 462 470 DRM_DEBUG_KMS("[CRTC:%d] [NOFB]\n", set->crtc->base.id); 463 - return drm_crtc_helper_disable(set->crtc); 471 + drm_crtc_helper_disable(set->crtc); 472 + return 0; 464 473 } 465 474 466 475 dev = set->crtc->dev;
+1 -1
drivers/gpu/drm/drm_dp_helper.c
··· 206 206 * i2c_dp_aux_add_bus() - register an i2c adapter using the aux ch helper 207 207 * @adapter: i2c adapter to register 208 208 * 209 - * This registers an i2c adapater that uses dp aux channel as it's underlaying 209 + * This registers an i2c adapter that uses dp aux channel as it's underlaying 210 210 * transport. The driver needs to fill out the &i2c_algo_dp_aux_data structure 211 211 * and store it in the algo_data member of the @adapter argument. This will be 212 212 * used by the i2c over dp aux algorithm to drive the hardware.
+105 -56
drivers/gpu/drm/drm_edid.c
··· 984 984 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 985 985 }; 986 986 987 - /* 988 - * Sanity check the header of the base EDID block. Return 8 if the header 989 - * is perfect, down to 0 if it's totally wrong. 987 + /** 988 + * drm_edid_header_is_valid - sanity check the header of the base EDID block 989 + * @raw_edid: pointer to raw base EDID block 990 + * 991 + * Sanity check the header of the base EDID block. 992 + * 993 + * Return: 8 if the header is perfect, down to 0 if it's totally wrong. 990 994 */ 991 995 int drm_edid_header_is_valid(const u8 *raw_edid) 992 996 { ··· 1009 1005 MODULE_PARM_DESC(edid_fixup, 1010 1006 "Minimum number of valid EDID header bytes (0-8, default 6)"); 1011 1007 1012 - /* 1013 - * Sanity check the EDID block (base or extension). Return 0 if the block 1014 - * doesn't check out, or 1 if it's valid. 1008 + /** 1009 + * drm_edid_block_valid - Sanity check the EDID block (base or extension) 1010 + * @raw_edid: pointer to raw EDID block 1011 + * @block: type of block to validate (0 for base, extension otherwise) 1012 + * @print_bad_edid: if true, dump bad EDID blocks to the console 1013 + * 1014 + * Validate a base or extension EDID block and optionally dump bad blocks to 1015 + * the console. 1016 + * 1017 + * Return: True if the block is valid, false otherwise. 1015 1018 */ 1016 1019 bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid) 1017 1020 { ··· 1088 1077 * @edid: EDID data 1089 1078 * 1090 1079 * Sanity-check an entire EDID record (including extensions) 1080 + * 1081 + * Return: True if the EDID data is valid, false otherwise. 1091 1082 */ 1092 1083 bool drm_edid_is_valid(struct edid *edid) 1093 1084 { ··· 1109 1096 1110 1097 #define DDC_SEGMENT_ADDR 0x30 1111 1098 /** 1112 - * Get EDID information via I2C. 1113 - * 1114 - * @adapter : i2c device adaptor 1099 + * drm_do_probe_ddc_edid() - get EDID information via I2C 1100 + * @adapter: I2C device adaptor 1115 1101 * @buf: EDID data buffer to be filled 1116 1102 * @block: 128 byte EDID block to start fetching from 1117 1103 * @len: EDID data buffer length to fetch 1118 1104 * 1119 - * Returns: 1105 + * Try to fetch EDID information by calling I2C driver functions. 1120 1106 * 1121 - * 0 on success or -1 on failure. 1122 - * 1123 - * Try to fetch EDID information by calling i2c driver function. 1107 + * Return: 0 on success or -1 on failure. 1124 1108 */ 1125 1109 static int 1126 1110 drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf, ··· 1128 1118 unsigned char xfers = segment ? 3 : 2; 1129 1119 int ret, retries = 5; 1130 1120 1131 - /* The core i2c driver will automatically retry the transfer if the 1121 + /* 1122 + * The core I2C driver will automatically retry the transfer if the 1132 1123 * adapter reports EAGAIN. However, we find that bit-banging transfers 1133 1124 * are susceptible to errors under a heavily loaded machine and 1134 1125 * generate spurious NAKs and timeouts. Retrying the transfer ··· 1155 1144 } 1156 1145 }; 1157 1146 1158 - /* 1159 - * Avoid sending the segment addr to not upset non-compliant ddc 1160 - * monitors. 1161 - */ 1147 + /* 1148 + * Avoid sending the segment addr to not upset non-compliant 1149 + * DDC monitors. 1150 + */ 1162 1151 ret = i2c_transfer(adapter, &msgs[3 - xfers], xfers); 1163 1152 1164 1153 if (ret == -ENXIO) { ··· 1257 1246 } 1258 1247 1259 1248 /** 1260 - * Probe DDC presence. 1261 - * @adapter: i2c adapter to probe 1249 + * drm_probe_ddc() - probe DDC presence 1250 + * @adapter: I2C adapter to probe 1262 1251 * 1263 - * Returns: 1264 - * 1265 - * 1 on success 1252 + * Return: True on success, false on failure. 1266 1253 */ 1267 1254 bool 1268 1255 drm_probe_ddc(struct i2c_adapter *adapter) ··· 1274 1265 /** 1275 1266 * drm_get_edid - get EDID data, if available 1276 1267 * @connector: connector we're probing 1277 - * @adapter: i2c adapter to use for DDC 1268 + * @adapter: I2C adapter to use for DDC 1278 1269 * 1279 - * Poke the given i2c channel to grab EDID data if possible. If found, 1270 + * Poke the given I2C channel to grab EDID data if possible. If found, 1280 1271 * attach it to the connector. 1281 1272 * 1282 - * Return edid data or NULL if we couldn't find any. 1273 + * Return: Pointer to valid EDID or NULL if we couldn't find any. 1283 1274 */ 1284 1275 struct edid *drm_get_edid(struct drm_connector *connector, 1285 1276 struct i2c_adapter *adapter) ··· 1297 1288 * drm_edid_duplicate - duplicate an EDID and the extensions 1298 1289 * @edid: EDID to duplicate 1299 1290 * 1300 - * Return duplicate edid or NULL on allocation failure. 1291 + * Return: Pointer to duplicated EDID or NULL on allocation failure. 1301 1292 */ 1302 1293 struct edid *drm_edid_duplicate(const struct edid *edid) 1303 1294 { ··· 1420 1411 * @rb: Mode reduced-blanking-ness 1421 1412 * 1422 1413 * Walk the DMT mode list looking for a match for the given parameters. 1423 - * Return a newly allocated copy of the mode, or NULL if not found. 1414 + * 1415 + * Return: A newly allocated copy of the mode, or NULL if not found. 1424 1416 */ 1425 1417 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, 1426 1418 int hsize, int vsize, int fresh, ··· 1605 1595 * @connector: connector of for the EDID block 1606 1596 * @edid: EDID block to scan 1607 1597 * @t: standard timing params 1608 - * @revision: standard timing level 1609 1598 * 1610 1599 * Take the standard timing params (in this case width, aspect, and refresh) 1611 1600 * and convert them into a real mode using CVT/GTF/DMT. 1612 1601 */ 1613 1602 static struct drm_display_mode * 1614 1603 drm_mode_std(struct drm_connector *connector, struct edid *edid, 1615 - struct std_timing *t, int revision) 1604 + struct std_timing *t) 1616 1605 { 1617 1606 struct drm_device *dev = connector->dev; 1618 1607 struct drm_display_mode *m, *mode = NULL; ··· 1632 1623 vrefresh_rate = vfreq + 60; 1633 1624 /* the vdisplay is calculated based on the aspect ratio */ 1634 1625 if (aspect_ratio == 0) { 1635 - if (revision < 3) 1626 + if (edid->revision < 3) 1636 1627 vsize = hsize; 1637 1628 else 1638 1629 vsize = (hsize * 10) / 16; ··· 2149 2140 2150 2141 /** 2151 2142 * add_established_modes - get est. modes from EDID and add them 2152 - * @connector: connector of for the EDID block 2143 + * @connector: connector to add mode(s) to 2153 2144 * @edid: EDID block to scan 2154 2145 * 2155 2146 * Each EDID block contains a bitmap of the supported "established modes" list ··· 2200 2191 struct drm_display_mode *newmode; 2201 2192 2202 2193 std = &data->data.timings[i]; 2203 - newmode = drm_mode_std(connector, edid, std, 2204 - edid->revision); 2194 + newmode = drm_mode_std(connector, edid, std); 2205 2195 if (newmode) { 2206 2196 drm_mode_probed_add(connector, newmode); 2207 2197 closure->modes++; ··· 2211 2203 2212 2204 /** 2213 2205 * add_standard_modes - get std. modes from EDID and add them 2214 - * @connector: connector of for the EDID block 2206 + * @connector: connector to add mode(s) to 2215 2207 * @edid: EDID block to scan 2216 2208 * 2217 2209 * Standard modes can be calculated using the appropriate standard (DMT, ··· 2229 2221 struct drm_display_mode *newmode; 2230 2222 2231 2223 newmode = drm_mode_std(connector, edid, 2232 - &edid->standard_timings[i], 2233 - edid->revision); 2224 + &edid->standard_timings[i]); 2234 2225 if (newmode) { 2235 2226 drm_mode_probed_add(connector, newmode); 2236 2227 modes++; ··· 2432 2425 * drm_match_cea_mode - look for a CEA mode matching given mode 2433 2426 * @to_match: display mode 2434 2427 * 2435 - * Returns the CEA Video ID (VIC) of the mode or 0 if it isn't a CEA-861 2428 + * Return: The CEA Video ID (VIC) of the mode or 0 if it isn't a CEA-861 2436 2429 * mode. 2437 2430 */ 2438 2431 u8 drm_match_cea_mode(const struct drm_display_mode *to_match) ··· 2458 2451 return 0; 2459 2452 } 2460 2453 EXPORT_SYMBOL(drm_match_cea_mode); 2454 + 2455 + /** 2456 + * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to 2457 + * the input VIC from the CEA mode list 2458 + * @video_code: ID given to each of the CEA modes 2459 + * 2460 + * Returns picture aspect ratio 2461 + */ 2462 + enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code) 2463 + { 2464 + /* return picture aspect ratio for video_code - 1 to access the 2465 + * right array element 2466 + */ 2467 + return edid_cea_modes[video_code-1].picture_aspect_ratio; 2468 + } 2469 + EXPORT_SYMBOL(drm_get_cea_aspect_ratio); 2461 2470 2462 2471 /* 2463 2472 * Calculate the alternate clock for HDMI modes (those from the HDMI vendor ··· 3046 3023 * @connector: connector corresponding to the HDMI/DP sink 3047 3024 * @edid: EDID to parse 3048 3025 * 3049 - * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. 3050 - * Some ELD fields are left to the graphics driver caller: 3051 - * - Conn_Type 3052 - * - HDCP 3053 - * - Port_ID 3026 + * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The 3027 + * Conn_Type, HDCP and Port_ID ELD fields are left for the graphics driver to 3028 + * fill in. 3054 3029 */ 3055 3030 void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) 3056 3031 { ··· 3132 3111 * @sads: pointer that will be set to the extracted SADs 3133 3112 * 3134 3113 * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it. 3135 - * Note: returned pointer needs to be kfreed 3136 3114 * 3137 - * Return number of found SADs or negative number on error. 3115 + * Note: The returned pointer needs to be freed using kfree(). 3116 + * 3117 + * Return: The number of found SADs or negative number on error. 3138 3118 */ 3139 3119 int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads) 3140 3120 { ··· 3192 3170 * @sadb: pointer to the speaker block 3193 3171 * 3194 3172 * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it. 3195 - * Note: returned pointer needs to be kfreed 3196 3173 * 3197 - * Return number of found Speaker Allocation Blocks or negative number on error. 3174 + * Note: The returned pointer needs to be freed using kfree(). 3175 + * 3176 + * Return: The number of found Speaker Allocation Blocks or negative number on 3177 + * error. 3198 3178 */ 3199 3179 int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) 3200 3180 { ··· 3243 3219 EXPORT_SYMBOL(drm_edid_to_speaker_allocation); 3244 3220 3245 3221 /** 3246 - * drm_av_sync_delay - HDMI/DP sink audio-video sync delay in millisecond 3222 + * drm_av_sync_delay - compute the HDMI/DP sink audio-video sync delay 3247 3223 * @connector: connector associated with the HDMI/DP sink 3248 3224 * @mode: the display mode 3225 + * 3226 + * Return: The HDMI/DP sink's audio-video sync delay in milliseconds or 0 if 3227 + * the sink doesn't support audio or video. 3249 3228 */ 3250 3229 int drm_av_sync_delay(struct drm_connector *connector, 3251 3230 struct drm_display_mode *mode) ··· 3290 3263 * 3291 3264 * It's possible for one encoder to be associated with multiple HDMI/DP sinks. 3292 3265 * The policy is now hard coded to simply use the first HDMI/DP sink's ELD. 3266 + * 3267 + * Return: The connector associated with the first HDMI/DP sink that has ELD 3268 + * attached to it. 3293 3269 */ 3294 3270 struct drm_connector *drm_select_eld(struct drm_encoder *encoder, 3295 3271 struct drm_display_mode *mode) ··· 3309 3279 EXPORT_SYMBOL(drm_select_eld); 3310 3280 3311 3281 /** 3312 - * drm_detect_hdmi_monitor - detect whether monitor is hdmi. 3282 + * drm_detect_hdmi_monitor - detect whether monitor is HDMI 3313 3283 * @edid: monitor EDID information 3314 3284 * 3315 3285 * Parse the CEA extension according to CEA-861-B. 3316 - * Return true if HDMI, false if not or unknown. 3286 + * 3287 + * Return: True if the monitor is HDMI, false if not or unknown. 3317 3288 */ 3318 3289 bool drm_detect_hdmi_monitor(struct edid *edid) 3319 3290 { ··· 3352 3321 * audio format, assume at least 'basic audio' support, even if 'basic 3353 3322 * audio' is not defined in EDID. 3354 3323 * 3324 + * Return: True if the monitor supports audio, false otherwise. 3355 3325 */ 3356 3326 bool drm_detect_monitor_audio(struct edid *edid) 3357 3327 { ··· 3396 3364 * Check whether the monitor reports the RGB quantization range selection 3397 3365 * as supported. The AVI infoframe can then be used to inform the monitor 3398 3366 * which quantization range (full or limited) is used. 3367 + * 3368 + * Return: True if the RGB quantization range is selectable, false otherwise. 3399 3369 */ 3400 3370 bool drm_rgb_quant_range_selectable(struct edid *edid) 3401 3371 { ··· 3502 3468 /** 3503 3469 * drm_add_edid_modes - add modes from EDID data, if available 3504 3470 * @connector: connector we're probing 3505 - * @edid: edid data 3471 + * @edid: EDID data 3506 3472 * 3507 3473 * Add the specified modes to the connector's mode list. 3508 3474 * 3509 - * Return number of modes added or 0 if we couldn't find any. 3475 + * Return: The number of modes added or 0 if we couldn't find any. 3510 3476 */ 3511 3477 int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) 3512 3478 { ··· 3568 3534 * Add the specified modes to the connector's mode list. Only when the 3569 3535 * hdisplay/vdisplay is not beyond the given limit, it will be added. 3570 3536 * 3571 - * Return number of modes added or 0 if we couldn't find any. 3537 + * Return: The number of modes added or 0 if we couldn't find any. 3572 3538 */ 3573 3539 int drm_add_modes_noedid(struct drm_connector *connector, 3574 3540 int hdisplay, int vdisplay) ··· 3607 3573 } 3608 3574 EXPORT_SYMBOL(drm_add_modes_noedid); 3609 3575 3576 + /** 3577 + * drm_set_preferred_mode - Sets the preferred mode of a connector 3578 + * @connector: connector whose mode list should be processed 3579 + * @hpref: horizontal resolution of preferred mode 3580 + * @vpref: vertical resolution of preferred mode 3581 + * 3582 + * Marks a mode as preferred if it matches the resolution specified by @hpref 3583 + * and @vpref. 3584 + */ 3610 3585 void drm_set_preferred_mode(struct drm_connector *connector, 3611 3586 int hpref, int vpref) 3612 3587 { 3613 3588 struct drm_display_mode *mode; 3614 3589 3615 3590 list_for_each_entry(mode, &connector->probed_modes, head) { 3616 - if (mode->hdisplay == hpref && 3591 + if (mode->hdisplay == hpref && 3617 3592 mode->vdisplay == vpref) 3618 3593 mode->type |= DRM_MODE_TYPE_PREFERRED; 3619 3594 } ··· 3635 3592 * @frame: HDMI AVI infoframe 3636 3593 * @mode: DRM display mode 3637 3594 * 3638 - * Returns 0 on success or a negative error code on failure. 3595 + * Return: 0 on success or a negative error code on failure. 3639 3596 */ 3640 3597 int 3641 3598 drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, ··· 3656 3613 frame->video_code = drm_match_cea_mode(mode); 3657 3614 3658 3615 frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; 3616 + 3617 + /* Populate picture aspect ratio from CEA mode list */ 3618 + if (frame->video_code > 0) 3619 + frame->picture_aspect = drm_get_cea_aspect_ratio( 3620 + frame->video_code); 3621 + 3659 3622 frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE; 3660 3623 frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN; 3661 3624 ··· 3706 3657 * 4k or stereoscopic 3D mode. So when giving any other mode as input this 3707 3658 * function will return -EINVAL, error that can be safely ignored. 3708 3659 * 3709 - * Returns 0 on success or a negative error code on failure. 3660 + * Return: 0 on success or a negative error code on failure. 3710 3661 */ 3711 3662 int 3712 3663 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
+13 -4
drivers/gpu/drm/drm_fb_helper.c
··· 45 45 * DOC: fbdev helpers 46 46 * 47 47 * The fb helper functions are useful to provide an fbdev on top of a drm kernel 48 - * mode setting driver. They can be used mostly independantely from the crtc 48 + * mode setting driver. They can be used mostly independently from the crtc 49 49 * helper functions used by many drivers to implement the kernel mode setting 50 50 * interfaces. 51 51 * 52 52 * Initialization is done as a three-step process with drm_fb_helper_init(), 53 53 * drm_fb_helper_single_add_all_connectors() and drm_fb_helper_initial_config(). 54 - * Drivers with fancier requirements than the default beheviour can override the 54 + * Drivers with fancier requirements than the default behaviour can override the 55 55 * second step with their own code. Teardown is done with drm_fb_helper_fini(). 56 56 * 57 57 * At runtime drivers should restore the fbdev console by calling ··· 59 59 * should also notify the fb helper code from updates to the output 60 60 * configuration by calling drm_fb_helper_hotplug_event(). For easier 61 61 * integration with the output polling code in drm_crtc_helper.c the modeset 62 - * code proves a ->output_poll_changed callback. 62 + * code provides a ->output_poll_changed callback. 63 63 * 64 64 * All other functions exported by the fb helper library can be used to 65 65 * implement the fbdev driver interface by the driver. ··· 326 326 return false; 327 327 328 328 list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { 329 - if (helper->dev->switch_power_state == DRM_SWITCH_POWER_OFF) 329 + struct drm_device *dev = helper->dev; 330 + 331 + if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 330 332 continue; 333 + 334 + if (!mutex_trylock(&dev->mode_config.mutex)) { 335 + error = true; 336 + continue; 337 + } 331 338 332 339 ret = drm_fb_helper_restore_fbdev_mode(helper); 333 340 if (ret) 334 341 error = true; 342 + 343 + mutex_unlock(&dev->mode_config.mutex); 335 344 } 336 345 return error; 337 346 }
+3 -6
drivers/gpu/drm/drm_fops.c
··· 43 43 DEFINE_MUTEX(drm_global_mutex); 44 44 EXPORT_SYMBOL(drm_global_mutex); 45 45 46 - static int drm_open_helper(struct inode *inode, struct file *filp, 47 - struct drm_minor *minor); 46 + static int drm_open_helper(struct file *filp, struct drm_minor *minor); 48 47 49 48 static int drm_setup(struct drm_device * dev) 50 49 { ··· 94 95 /* share address_space across all char-devs of a single device */ 95 96 filp->f_mapping = dev->anon_inode->i_mapping; 96 97 97 - retcode = drm_open_helper(inode, filp, minor); 98 + retcode = drm_open_helper(filp, minor); 98 99 if (retcode) 99 100 goto err_undo; 100 101 if (need_setup) { ··· 170 171 /** 171 172 * Called whenever a process opens /dev/drm. 172 173 * 173 - * \param inode device inode. 174 174 * \param filp file pointer. 175 175 * \param minor acquired minor-object. 176 176 * \return zero on success or a negative number on failure. ··· 177 179 * Creates and initializes a drm_file structure for the file private data in \p 178 180 * filp and add it into the double linked list in \p dev. 179 181 */ 180 - static int drm_open_helper(struct inode *inode, struct file *filp, 181 - struct drm_minor *minor) 182 + static int drm_open_helper(struct file *filp, struct drm_minor *minor) 182 183 { 183 184 struct drm_device *dev = minor->dev; 184 185 struct drm_file *priv;
+3 -10
drivers/gpu/drm/drm_plane_helper.c
··· 124 124 .y2 = crtc->mode.vdisplay, 125 125 }; 126 126 struct drm_connector **connector_list; 127 - struct drm_framebuffer *tmpfb; 128 127 int num_connectors, ret; 129 128 130 129 if (!crtc->enabled) { ··· 144 145 } 145 146 146 147 /* Disallow scaling */ 148 + src_w >>= 16; 149 + src_h >>= 16; 147 150 if (crtc_w != src_w || crtc_h != src_h) { 148 151 DRM_DEBUG_KMS("Can't scale primary plane\n"); 149 152 return -EINVAL; ··· 177 176 set.num_connectors = num_connectors; 178 177 179 178 /* 180 - * set_config() adjusts crtc->primary->fb; however the DRM setplane 181 - * code that called us expects to handle the framebuffer update and 182 - * reference counting; save and restore the current fb before 183 - * calling it. 184 - * 185 - * N.B., we call set_config() directly here rather than using 179 + * We call set_config() directly here rather than using 186 180 * drm_mode_set_config_internal. We're reprogramming the same 187 181 * connectors that were already in use, so we shouldn't need the extra 188 182 * cross-CRTC fb refcounting to accomodate stealing connectors. 189 183 * drm_mode_setplane() already handles the basic refcounting for the 190 184 * framebuffers involved in this operation. 191 185 */ 192 - tmpfb = plane->fb; 193 186 ret = crtc->funcs->set_config(&set); 194 - plane->fb = tmpfb; 195 187 196 188 kfree(connector_list); 197 189 return ret; ··· 226 232 */ 227 233 void drm_primary_helper_destroy(struct drm_plane *plane) 228 234 { 229 - plane->funcs->disable_plane(plane); 230 235 drm_plane_cleanup(plane); 231 236 kfree(plane); 232 237 }
+1 -1
drivers/gpu/drm/drm_probe_helper.c
··· 151 151 drm_mode_validate_flag(connector, mode_flags); 152 152 153 153 list_for_each_entry(mode, &connector->modes, head) { 154 - if (mode->status == MODE_OK) 154 + if (mode->status == MODE_OK && connector_funcs->mode_valid) 155 155 mode->status = connector_funcs->mode_valid(connector, 156 156 mode); 157 157 }
-7
drivers/gpu/drm/exynos/exynos_dp_core.c
··· 949 949 return 1; 950 950 } 951 951 952 - static int exynos_dp_mode_valid(struct drm_connector *connector, 953 - struct drm_display_mode *mode) 954 - { 955 - return MODE_OK; 956 - } 957 - 958 952 static struct drm_encoder *exynos_dp_best_encoder( 959 953 struct drm_connector *connector) 960 954 { ··· 959 965 960 966 static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = { 961 967 .get_modes = exynos_dp_get_modes, 962 - .mode_valid = exynos_dp_mode_valid, 963 968 .best_encoder = exynos_dp_best_encoder, 964 969 }; 965 970
-7
drivers/gpu/drm/exynos/exynos_drm_dpi.c
··· 94 94 return 0; 95 95 } 96 96 97 - static int exynos_dpi_mode_valid(struct drm_connector *connector, 98 - struct drm_display_mode *mode) 99 - { 100 - return MODE_OK; 101 - } 102 - 103 97 static struct drm_encoder * 104 98 exynos_dpi_best_encoder(struct drm_connector *connector) 105 99 { ··· 104 110 105 111 static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = { 106 112 .get_modes = exynos_dpi_get_modes, 107 - .mode_valid = exynos_dpi_mode_valid, 108 113 .best_encoder = exynos_dpi_best_encoder, 109 114 }; 110 115
-7
drivers/gpu/drm/exynos/exynos_drm_vidi.c
··· 533 533 return drm_add_edid_modes(connector, edid); 534 534 } 535 535 536 - static int vidi_mode_valid(struct drm_connector *connector, 537 - struct drm_display_mode *mode) 538 - { 539 - return MODE_OK; 540 - } 541 - 542 536 static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector) 543 537 { 544 538 struct vidi_context *ctx = ctx_from_connector(connector); ··· 542 548 543 549 static struct drm_connector_helper_funcs vidi_connector_helper_funcs = { 544 550 .get_modes = vidi_get_modes, 545 - .mode_valid = vidi_mode_valid, 546 551 .best_encoder = vidi_best_encoder, 547 552 }; 548 553
-7
drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
··· 57 57 return 1; 58 58 } 59 59 60 - static int rcar_du_lvds_connector_mode_valid(struct drm_connector *connector, 61 - struct drm_display_mode *mode) 62 - { 63 - return MODE_OK; 64 - } 65 - 66 60 static const struct drm_connector_helper_funcs connector_helper_funcs = { 67 61 .get_modes = rcar_du_lvds_connector_get_modes, 68 - .mode_valid = rcar_du_lvds_connector_mode_valid, 69 62 .best_encoder = rcar_du_connector_best_encoder, 70 63 }; 71 64
-7
drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
··· 25 25 return 0; 26 26 } 27 27 28 - static int rcar_du_vga_connector_mode_valid(struct drm_connector *connector, 29 - struct drm_display_mode *mode) 30 - { 31 - return MODE_OK; 32 - } 33 - 34 28 static const struct drm_connector_helper_funcs connector_helper_funcs = { 35 29 .get_modes = rcar_du_vga_connector_get_modes, 36 - .mode_valid = rcar_du_vga_connector_mode_valid, 37 30 .best_encoder = rcar_du_connector_best_encoder, 38 31 }; 39 32
-7
drivers/gpu/drm/shmobile/shmob_drm_crtc.c
··· 674 674 return 1; 675 675 } 676 676 677 - static int shmob_drm_connector_mode_valid(struct drm_connector *connector, 678 - struct drm_display_mode *mode) 679 - { 680 - return MODE_OK; 681 - } 682 - 683 677 static struct drm_encoder * 684 678 shmob_drm_connector_best_encoder(struct drm_connector *connector) 685 679 { ··· 684 690 685 691 static const struct drm_connector_helper_funcs connector_helper_funcs = { 686 692 .get_modes = shmob_drm_connector_get_modes, 687 - .mode_valid = shmob_drm_connector_mode_valid, 688 693 .best_encoder = shmob_drm_connector_best_encoder, 689 694 }; 690 695
-7
drivers/staging/imx-drm/imx-drm-core.c
··· 200 200 .llseek = noop_llseek, 201 201 }; 202 202 203 - int imx_drm_connector_mode_valid(struct drm_connector *connector, 204 - struct drm_display_mode *mode) 205 - { 206 - return MODE_OK; 207 - } 208 - EXPORT_SYMBOL(imx_drm_connector_mode_valid); 209 - 210 203 void imx_drm_connector_destroy(struct drm_connector *connector) 211 204 { 212 205 drm_sysfs_connector_remove(connector);
-2
drivers/staging/imx-drm/imx-drm.h
··· 50 50 int imx_drm_encoder_parse_of(struct drm_device *drm, 51 51 struct drm_encoder *encoder, struct device_node *np); 52 52 53 - int imx_drm_connector_mode_valid(struct drm_connector *connector, 54 - struct drm_display_mode *mode); 55 53 void imx_drm_connector_destroy(struct drm_connector *connector); 56 54 void imx_drm_encoder_destroy(struct drm_encoder *encoder); 57 55
-1
drivers/staging/imx-drm/imx-hdmi.c
··· 1492 1492 1493 1493 static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = { 1494 1494 .get_modes = imx_hdmi_connector_get_modes, 1495 - .mode_valid = imx_drm_connector_mode_valid, 1496 1495 .best_encoder = imx_hdmi_connector_best_encoder, 1497 1496 }; 1498 1497
-1
drivers/staging/imx-drm/imx-ldb.c
··· 317 317 static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = { 318 318 .get_modes = imx_ldb_connector_get_modes, 319 319 .best_encoder = imx_ldb_connector_best_encoder, 320 - .mode_valid = imx_drm_connector_mode_valid, 321 320 }; 322 321 323 322 static struct drm_encoder_funcs imx_ldb_encoder_funcs = {
-4
drivers/staging/imx-drm/imx-tve.c
··· 251 251 unsigned long rate; 252 252 int ret; 253 253 254 - ret = imx_drm_connector_mode_valid(connector, mode); 255 - if (ret != MODE_OK) 256 - return ret; 257 - 258 254 /* pixel clock with 2x oversampling */ 259 255 rate = clk_round_rate(tve->clk, 2000UL * mode->clock) / 2000; 260 256 if (rate == mode->clock)
-1
drivers/staging/imx-drm/parallel-display.c
··· 148 148 static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = { 149 149 .get_modes = imx_pd_connector_get_modes, 150 150 .best_encoder = imx_pd_connector_best_encoder, 151 - .mode_valid = imx_drm_connector_mode_valid, 152 151 }; 153 152 154 153 static struct drm_encoder_funcs imx_pd_encoder_funcs = {
+1
include/drm/drm_crtc.h
··· 1021 1021 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, 1022 1022 void *data, struct drm_file *file_priv); 1023 1023 extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match); 1024 + extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); 1024 1025 extern bool drm_detect_hdmi_monitor(struct edid *edid); 1025 1026 extern bool drm_detect_monitor_audio(struct edid *edid); 1026 1027 extern bool drm_rgb_quant_range_selectable(struct edid *edid);
+1 -1
include/drm/drm_crtc_helper.h
··· 114 114 /** 115 115 * drm_connector_helper_funcs - helper operations for connectors 116 116 * @get_modes: get mode list for this connector 117 - * @mode_valid: is this mode valid on the given connector? 117 + * @mode_valid (optional): is this mode valid on the given connector? 118 118 * 119 119 * The helper operations are called by the mid-layer CRTC helper. 120 120 */
+1
include/drm/drm_flip_work.h
··· 57 57 * @count: number of committed items 58 58 * @func: callback fxn called for each committed item 59 59 * @worker: worker which calls @func 60 + * @fifo: queue of committed items 60 61 */ 61 62 struct drm_flip_work { 62 63 const char *name;