diff options
author | Lespiau, Damien <damien.lespiau@intel.com> | 2013-08-19 11:58:58 -0400 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2013-08-29 18:40:45 -0400 |
commit | 7d27becb3532d881378846e72864031977be511a (patch) | |
tree | 3171b5326dfd4d546efff20566543612957d53ba /drivers/video | |
parent | 974e0701c5251de879624d166890fbd0ee9fc429 (diff) |
video/hdmi: Introduce helpers for the HDMI vendor specific infoframe
Provide the same programming model than the other infoframe types.
The generic _pack() function can't handle those yet as we need to move
the vendor OUI in the generic hdmi_vendor_infoframe structure to know
which kind of vendor infoframe we are dealing with.
v2: Fix the value of Side-by-side (half), hmdi typo, pack 3D_Ext_Data
(Ville Syrjälä)
v3: Future proof the sending of 3D_Ext_Data (Ville Syrjälä), Fix
multi-lines comment style (Thierry Reding)
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/hdmi.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c index 1201357f3e3c..4c42bcb86535 100644 --- a/drivers/video/hdmi.c +++ b/drivers/video/hdmi.c | |||
@@ -288,6 +288,96 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, | |||
288 | EXPORT_SYMBOL(hdmi_audio_infoframe_pack); | 288 | EXPORT_SYMBOL(hdmi_audio_infoframe_pack); |
289 | 289 | ||
290 | /** | 290 | /** |
291 | * hdmi_hdmi_infoframe_init() - initialize an 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_hdmi_infoframe_init(struct hdmi_hdmi_infoframe *frame) | ||
297 | { | ||
298 | memset(frame, 0, sizeof(*frame)); | ||
299 | |||
300 | frame->type = HDMI_INFOFRAME_TYPE_VENDOR; | ||
301 | frame->version = 1; | ||
302 | |||
303 | /* | ||
304 | * 0 is a valid value for s3d_struct, so we use a special "not set" | ||
305 | * value | ||
306 | */ | ||
307 | frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID; | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | EXPORT_SYMBOL(hdmi_hdmi_infoframe_init); | ||
312 | |||
313 | /** | ||
314 | * hdmi_hdmi_infoframe_pack() - write a HDMI vendor infoframe to binary buffer | ||
315 | * @frame: HDMI infoframe | ||
316 | * @buffer: destination buffer | ||
317 | * @size: size of buffer | ||
318 | * | ||
319 | * Packs the information contained in the @frame structure into a binary | ||
320 | * representation that can be written into the corresponding controller | ||
321 | * registers. Also computes the checksum as required by section 5.3.5 of | ||
322 | * the HDMI 1.4 specification. | ||
323 | * | ||
324 | * Returns the number of bytes packed into the binary buffer or a negative | ||
325 | * error code on failure. | ||
326 | */ | ||
327 | ssize_t hdmi_hdmi_infoframe_pack(struct hdmi_hdmi_infoframe *frame, | ||
328 | void *buffer, size_t size) | ||
329 | { | ||
330 | u8 *ptr = buffer; | ||
331 | size_t length; | ||
332 | |||
333 | /* empty info frame */ | ||
334 | if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID) | ||
335 | return -EINVAL; | ||
336 | |||
337 | /* only one of those can be supplied */ | ||
338 | if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) | ||
339 | return -EINVAL; | ||
340 | |||
341 | /* for side by side (half) we also need to provide 3D_Ext_Data */ | ||
342 | if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) | ||
343 | frame->length = 6; | ||
344 | else | ||
345 | frame->length = 5; | ||
346 | |||
347 | length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; | ||
348 | |||
349 | if (size < length) | ||
350 | return -ENOSPC; | ||
351 | |||
352 | memset(buffer, 0, size); | ||
353 | |||
354 | ptr[0] = frame->type; | ||
355 | ptr[1] = frame->version; | ||
356 | ptr[2] = frame->length; | ||
357 | ptr[3] = 0; /* checksum */ | ||
358 | |||
359 | /* HDMI OUI */ | ||
360 | ptr[4] = 0x03; | ||
361 | ptr[5] = 0x0c; | ||
362 | ptr[6] = 0x00; | ||
363 | |||
364 | if (frame->vic) { | ||
365 | ptr[7] = 0x1 << 5; /* video format */ | ||
366 | ptr[8] = frame->vic; | ||
367 | } else { | ||
368 | ptr[7] = 0x2 << 5; /* video format */ | ||
369 | ptr[8] = (frame->s3d_struct & 0xf) << 4; | ||
370 | if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) | ||
371 | ptr[9] = (frame->s3d_ext_data & 0xf) << 4; | ||
372 | } | ||
373 | |||
374 | hdmi_infoframe_checksum(buffer, length); | ||
375 | |||
376 | return length; | ||
377 | } | ||
378 | EXPORT_SYMBOL(hdmi_hdmi_infoframe_pack); | ||
379 | |||
380 | /** | ||
291 | * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary | 381 | * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary |
292 | * buffer | 382 | * buffer |
293 | * @frame: HDMI vendor infoframe | 383 | * @frame: HDMI vendor infoframe |