diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-05 13:17:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-05 13:17:26 -0400 |
commit | a09e9a7a4b907f2dfa9bdb2b98a1828ab4b340b2 (patch) | |
tree | c7a2df4e887573648eeaf8f7939889046990d3f6 /drivers/video | |
parent | 9ab073bc45b8b523cc39658925bb44bef35ca657 (diff) | |
parent | 86a7e1224a68511d3a1ae0b7e11581b9d37723ae (diff) |
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm tree changes from Dave Airlie:
"This is the main drm pull request, I have some overlap with sound and
arm-soc, the sound patch is acked and may conflict based on -next
reports but should be a trivial fixup, which I'll leave to you!
Highlights:
- new drivers:
MSM driver from Rob Clark
- non-drm:
switcheroo and hdmi audio driver support for secondary GPU
poweroff, so drivers can use runtime PM to poweroff the GPUs. This
can save 5 or 6W on some optimus laptops.
- drm core:
combined GEM and TTM VMA manager
per-filp mmap permission tracking
initial rendernode support (via a runtime enable for now, until we get api stable),
remove old proc support,
lots of cleanups of legacy code
hdmi vendor infoframes and 4k modes
lots of gem/prime locking and races fixes
async pageflip scaffolding
drm bridge objects
- i915:
Haswell PC8+ support and eLLC support, HDMI 4K support, initial
per-process VMA pieces, watermark reworks, convert to generic hdmi
infoframes, encoder reworking, fastboot support,
- radeon:
CIK PM support, remove 3d blit code in favour of DMA engines,
Berlin GPU support, HDMI audio fixes
- nouveau:
secondary GPU power down support for optimus laptops, lots of
fixes, use MSI, VP3 engine support
- exynos:
runtime pm support for g2d, DT support, remove non-DT,
- tda998x i2c driver:
lots of fixes for sync issues
- gma500:
lots of cleanups
- rcar:
add LVDS support, fbdev emulation,
- tegra:
just minor fixes"
* 'drm-next' of git://people.freedesktop.org/~airlied/linux: (684 commits)
drm/exynos: Fix build error with exynos_drm_connector.c
drm/exynos: Remove non-DT support in exynos_drm_fimd
drm/exynos: Remove non-DT support in exynos_hdmi
drm/exynos: Remove non-DT support in exynos_drm_g2d
drm/exynos: Remove non-DT support in exynos_hdmiphy
drm/exynos: Remove non-DT support in exynos_ddc
drm/exynos: Make Exynos DRM drivers depend on OF
drm/exynos: Consider fallback option to allocation fail
drm/exynos: fimd: move platform data parsing to separate function
drm/exynos: fimd: get signal polarities from device tree
drm/exynos: fimd: replace struct fb_videomode with videomode
drm/exynos: check a pixel format to a particular window layer
drm/exynos: fix fimd pixel format setting
drm/exynos: Add NULL pointer check
drm/exynos: Remove redundant error messages
drm/exynos: Add missing of.h header include
drm/exynos: Remove redundant NULL check in exynos_drm_buf
drm/exynos: add device tree support for rotator
drm/exynos: Add missing includes
drm/exynos: add runtime pm interfaces to g2d driver
...
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/hdmi.c | 141 |
1 files changed, 127 insertions, 14 deletions
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c index 40178338b619..9e758a8f890d 100644 --- a/drivers/video/hdmi.c +++ b/drivers/video/hdmi.c | |||
@@ -22,6 +22,7 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/bitops.h> | 24 | #include <linux/bitops.h> |
25 | #include <linux/bug.h> | ||
25 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
26 | #include <linux/export.h> | 27 | #include <linux/export.h> |
27 | #include <linux/hdmi.h> | 28 | #include <linux/hdmi.h> |
@@ -52,7 +53,7 @@ int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame) | |||
52 | 53 | ||
53 | frame->type = HDMI_INFOFRAME_TYPE_AVI; | 54 | frame->type = HDMI_INFOFRAME_TYPE_AVI; |
54 | frame->version = 2; | 55 | frame->version = 2; |
55 | frame->length = 13; | 56 | frame->length = HDMI_AVI_INFOFRAME_SIZE; |
56 | 57 | ||
57 | return 0; | 58 | return 0; |
58 | } | 59 | } |
@@ -83,7 +84,7 @@ ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, | |||
83 | if (size < length) | 84 | if (size < length) |
84 | return -ENOSPC; | 85 | return -ENOSPC; |
85 | 86 | ||
86 | memset(buffer, 0, length); | 87 | memset(buffer, 0, size); |
87 | 88 | ||
88 | ptr[0] = frame->type; | 89 | ptr[0] = frame->type; |
89 | ptr[1] = frame->version; | 90 | ptr[1] = frame->version; |
@@ -95,13 +96,18 @@ ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, | |||
95 | 96 | ||
96 | ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3); | 97 | ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3); |
97 | 98 | ||
98 | if (frame->active_info_valid) | 99 | /* |
100 | * Data byte 1, bit 4 has to be set if we provide the active format | ||
101 | * aspect ratio | ||
102 | */ | ||
103 | if (frame->active_aspect & 0xf) | ||
99 | ptr[0] |= BIT(4); | 104 | ptr[0] |= BIT(4); |
100 | 105 | ||
101 | if (frame->horizontal_bar_valid) | 106 | /* Bit 3 and 2 indicate if we transmit horizontal/vertical bar data */ |
107 | if (frame->top_bar || frame->bottom_bar) | ||
102 | ptr[0] |= BIT(3); | 108 | ptr[0] |= BIT(3); |
103 | 109 | ||
104 | if (frame->vertical_bar_valid) | 110 | if (frame->left_bar || frame->right_bar) |
105 | ptr[0] |= BIT(2); | 111 | ptr[0] |= BIT(2); |
106 | 112 | ||
107 | ptr[1] = ((frame->colorimetry & 0x3) << 6) | | 113 | ptr[1] = ((frame->colorimetry & 0x3) << 6) | |
@@ -151,7 +157,7 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, | |||
151 | 157 | ||
152 | frame->type = HDMI_INFOFRAME_TYPE_SPD; | 158 | frame->type = HDMI_INFOFRAME_TYPE_SPD; |
153 | frame->version = 1; | 159 | frame->version = 1; |
154 | frame->length = 25; | 160 | frame->length = HDMI_SPD_INFOFRAME_SIZE; |
155 | 161 | ||
156 | strncpy(frame->vendor, vendor, sizeof(frame->vendor)); | 162 | strncpy(frame->vendor, vendor, sizeof(frame->vendor)); |
157 | strncpy(frame->product, product, sizeof(frame->product)); | 163 | strncpy(frame->product, product, sizeof(frame->product)); |
@@ -185,7 +191,7 @@ ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, | |||
185 | if (size < length) | 191 | if (size < length) |
186 | return -ENOSPC; | 192 | return -ENOSPC; |
187 | 193 | ||
188 | memset(buffer, 0, length); | 194 | memset(buffer, 0, size); |
189 | 195 | ||
190 | ptr[0] = frame->type; | 196 | ptr[0] = frame->type; |
191 | ptr[1] = frame->version; | 197 | ptr[1] = frame->version; |
@@ -218,7 +224,7 @@ int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame) | |||
218 | 224 | ||
219 | frame->type = HDMI_INFOFRAME_TYPE_AUDIO; | 225 | frame->type = HDMI_INFOFRAME_TYPE_AUDIO; |
220 | frame->version = 1; | 226 | frame->version = 1; |
221 | frame->length = 10; | 227 | frame->length = HDMI_AUDIO_INFOFRAME_SIZE; |
222 | 228 | ||
223 | return 0; | 229 | return 0; |
224 | } | 230 | } |
@@ -250,7 +256,7 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, | |||
250 | if (size < length) | 256 | if (size < length) |
251 | return -ENOSPC; | 257 | return -ENOSPC; |
252 | 258 | ||
253 | memset(buffer, 0, length); | 259 | memset(buffer, 0, size); |
254 | 260 | ||
255 | if (frame->channels >= 2) | 261 | if (frame->channels >= 2) |
256 | channels = frame->channels - 1; | 262 | channels = frame->channels - 1; |
@@ -282,9 +288,33 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, | |||
282 | EXPORT_SYMBOL(hdmi_audio_infoframe_pack); | 288 | EXPORT_SYMBOL(hdmi_audio_infoframe_pack); |
283 | 289 | ||
284 | /** | 290 | /** |
285 | * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary | 291 | * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe |
286 | * buffer | ||
287 | * @frame: HDMI vendor infoframe | 292 | * @frame: HDMI vendor infoframe |
293 | * | ||
294 | * Returns 0 on success or a negative error code on failure. | ||
295 | */ | ||
296 | int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame) | ||
297 | { | ||
298 | memset(frame, 0, sizeof(*frame)); | ||
299 | |||
300 | frame->type = HDMI_INFOFRAME_TYPE_VENDOR; | ||
301 | frame->version = 1; | ||
302 | |||
303 | frame->oui = HDMI_IEEE_OUI; | ||
304 | |||
305 | /* | ||
306 | * 0 is a valid value for s3d_struct, so we use a special "not set" | ||
307 | * value | ||
308 | */ | ||
309 | frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID; | ||
310 | |||
311 | return 0; | ||
312 | } | ||
313 | EXPORT_SYMBOL(hdmi_vendor_infoframe_init); | ||
314 | |||
315 | /** | ||
316 | * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer | ||
317 | * @frame: HDMI infoframe | ||
288 | * @buffer: destination buffer | 318 | * @buffer: destination buffer |
289 | * @size: size of buffer | 319 | * @size: size of buffer |
290 | * | 320 | * |
@@ -297,27 +327,110 @@ EXPORT_SYMBOL(hdmi_audio_infoframe_pack); | |||
297 | * error code on failure. | 327 | * error code on failure. |
298 | */ | 328 | */ |
299 | ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, | 329 | ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, |
300 | void *buffer, size_t size) | 330 | void *buffer, size_t size) |
301 | { | 331 | { |
302 | u8 *ptr = buffer; | 332 | u8 *ptr = buffer; |
303 | size_t length; | 333 | size_t length; |
304 | 334 | ||
335 | /* empty info frame */ | ||
336 | if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID) | ||
337 | return -EINVAL; | ||
338 | |||
339 | /* only one of those can be supplied */ | ||
340 | if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) | ||
341 | return -EINVAL; | ||
342 | |||
343 | /* for side by side (half) we also need to provide 3D_Ext_Data */ | ||
344 | if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) | ||
345 | frame->length = 6; | ||
346 | else | ||
347 | frame->length = 5; | ||
348 | |||
305 | length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; | 349 | length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; |
306 | 350 | ||
307 | if (size < length) | 351 | if (size < length) |
308 | return -ENOSPC; | 352 | return -ENOSPC; |
309 | 353 | ||
310 | memset(buffer, 0, length); | 354 | memset(buffer, 0, size); |
311 | 355 | ||
312 | ptr[0] = frame->type; | 356 | ptr[0] = frame->type; |
313 | ptr[1] = frame->version; | 357 | ptr[1] = frame->version; |
314 | ptr[2] = frame->length; | 358 | ptr[2] = frame->length; |
315 | ptr[3] = 0; /* checksum */ | 359 | ptr[3] = 0; /* checksum */ |
316 | 360 | ||
317 | memcpy(&ptr[HDMI_INFOFRAME_HEADER_SIZE], frame->data, frame->length); | 361 | /* HDMI OUI */ |
362 | ptr[4] = 0x03; | ||
363 | ptr[5] = 0x0c; | ||
364 | ptr[6] = 0x00; | ||
365 | |||
366 | if (frame->vic) { | ||
367 | ptr[7] = 0x1 << 5; /* video format */ | ||
368 | ptr[8] = frame->vic; | ||
369 | } else { | ||
370 | ptr[7] = 0x2 << 5; /* video format */ | ||
371 | ptr[8] = (frame->s3d_struct & 0xf) << 4; | ||
372 | if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) | ||
373 | ptr[9] = (frame->s3d_ext_data & 0xf) << 4; | ||
374 | } | ||
318 | 375 | ||
319 | hdmi_infoframe_checksum(buffer, length); | 376 | hdmi_infoframe_checksum(buffer, length); |
320 | 377 | ||
321 | return length; | 378 | return length; |
322 | } | 379 | } |
323 | EXPORT_SYMBOL(hdmi_vendor_infoframe_pack); | 380 | EXPORT_SYMBOL(hdmi_vendor_infoframe_pack); |
381 | |||
382 | /* | ||
383 | * hdmi_vendor_any_infoframe_pack() - write a vendor infoframe to binary buffer | ||
384 | */ | ||
385 | static ssize_t | ||
386 | hdmi_vendor_any_infoframe_pack(union hdmi_vendor_any_infoframe *frame, | ||
387 | void *buffer, size_t size) | ||
388 | { | ||
389 | /* we only know about HDMI vendor infoframes */ | ||
390 | if (frame->any.oui != HDMI_IEEE_OUI) | ||
391 | return -EINVAL; | ||
392 | |||
393 | return hdmi_vendor_infoframe_pack(&frame->hdmi, buffer, size); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * hdmi_infoframe_pack() - write a HDMI infoframe to binary buffer | ||
398 | * @frame: HDMI infoframe | ||
399 | * @buffer: destination buffer | ||
400 | * @size: size of buffer | ||
401 | * | ||
402 | * Packs the information contained in the @frame structure into a binary | ||
403 | * representation that can be written into the corresponding controller | ||
404 | * registers. Also computes the checksum as required by section 5.3.5 of | ||
405 | * the HDMI 1.4 specification. | ||
406 | * | ||
407 | * Returns the number of bytes packed into the binary buffer or a negative | ||
408 | * error code on failure. | ||
409 | */ | ||
410 | ssize_t | ||
411 | hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size) | ||
412 | { | ||
413 | ssize_t length; | ||
414 | |||
415 | switch (frame->any.type) { | ||
416 | case HDMI_INFOFRAME_TYPE_AVI: | ||
417 | length = hdmi_avi_infoframe_pack(&frame->avi, buffer, size); | ||
418 | break; | ||
419 | case HDMI_INFOFRAME_TYPE_SPD: | ||
420 | length = hdmi_spd_infoframe_pack(&frame->spd, buffer, size); | ||
421 | break; | ||
422 | case HDMI_INFOFRAME_TYPE_AUDIO: | ||
423 | length = hdmi_audio_infoframe_pack(&frame->audio, buffer, size); | ||
424 | break; | ||
425 | case HDMI_INFOFRAME_TYPE_VENDOR: | ||
426 | length = hdmi_vendor_any_infoframe_pack(&frame->vendor, | ||
427 | buffer, size); | ||
428 | break; | ||
429 | default: | ||
430 | WARN(1, "Bad infoframe type %d\n", frame->any.type); | ||
431 | length = -EINVAL; | ||
432 | } | ||
433 | |||
434 | return length; | ||
435 | } | ||
436 | EXPORT_SYMBOL(hdmi_infoframe_pack); | ||