aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLespiau, Damien <damien.lespiau@intel.com>2013-08-19 11:59:01 -0400
committerDave Airlie <airlied@gmail.com>2013-08-29 18:41:30 -0400
commitaf3e95b40720cdf301eb85387c0a3dc4067cc551 (patch)
tree22590128866c81d879ff51ffb2d9b4d8d7d1b205
parentc782d2e73d1e69c863d03945907bc7fbc879a778 (diff)
video/hdmi: Hook the HDMI vendor infoframe with the generic _pack()
With this last bit, hdmi_infoframe_pack() is now able to pack any infoframe we support. At the same time, because it's impractical to make two commits out of this, we get rid of the version that encourages the open coding of the vendor infoframe packing. We can do so because the only user of this API has been ported in: Author: Damien Lespiau <damien.lespiau@intel.com> Date: Mon Aug 12 18:08:37 2013 +0100 gpu: host1x: Port the HDMI vendor infoframe code the common helpers v2: Change oui to be an unsigned int (Ville Syrjälä) 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>
-rw-r--r--drivers/video/hdmi.c46
-rw-r--r--include/linux/hdmi.h24
2 files changed, 22 insertions, 48 deletions
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 4c42bcb86535..fbccb88c2620 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -300,6 +300,8 @@ int hdmi_hdmi_infoframe_init(struct hdmi_hdmi_infoframe *frame)
300 frame->type = HDMI_INFOFRAME_TYPE_VENDOR; 300 frame->type = HDMI_INFOFRAME_TYPE_VENDOR;
301 frame->version = 1; 301 frame->version = 1;
302 302
303 frame->oui = HDMI_IDENTIFIER;
304
303 /* 305 /*
304 * 0 is a valid value for s3d_struct, so we use a special "not set" 306 * 0 is a valid value for s3d_struct, so we use a special "not set"
305 * value 307 * value
@@ -377,46 +379,18 @@ ssize_t hdmi_hdmi_infoframe_pack(struct hdmi_hdmi_infoframe *frame,
377} 379}
378EXPORT_SYMBOL(hdmi_hdmi_infoframe_pack); 380EXPORT_SYMBOL(hdmi_hdmi_infoframe_pack);
379 381
380/** 382/*
381 * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary 383 * hdmi_vendor_infoframe_pack() - write a vendor infoframe to binary buffer
382 * buffer
383 * @frame: HDMI vendor infoframe
384 * @buffer: destination buffer
385 * @size: size of buffer
386 *
387 * Packs the information contained in the @frame structure into a binary
388 * representation that can be written into the corresponding controller
389 * registers. Also computes the checksum as required by section 5.3.5 of
390 * the HDMI 1.4 specification.
391 *
392 * Returns the number of bytes packed into the binary buffer or a negative
393 * error code on failure.
394 */ 384 */
395ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, 385static ssize_t hdmi_vendor_infoframe_pack(union hdmi_vendor_infoframe *frame,
396 void *buffer, size_t size) 386 void *buffer, size_t size)
397{ 387{
398 u8 *ptr = buffer; 388 /* we only know about HDMI vendor infoframes */
399 size_t length; 389 if (frame->any.oui != HDMI_IDENTIFIER)
400 390 return -EINVAL;
401 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
402
403 if (size < length)
404 return -ENOSPC;
405
406 memset(buffer, 0, size);
407
408 ptr[0] = frame->type;
409 ptr[1] = frame->version;
410 ptr[2] = frame->length;
411 ptr[3] = 0; /* checksum */
412
413 memcpy(&ptr[HDMI_INFOFRAME_HEADER_SIZE], frame->data, frame->length);
414
415 hdmi_infoframe_checksum(buffer, length);
416 391
417 return length; 392 return hdmi_hdmi_infoframe_pack(&frame->hdmi, buffer, size);
418} 393}
419EXPORT_SYMBOL(hdmi_vendor_infoframe_pack);
420 394
421/** 395/**
422 * hdmi_infoframe_pack() - write a HDMI infoframe to binary buffer 396 * hdmi_infoframe_pack() - write a HDMI infoframe to binary buffer
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index 37e0cd755284..e24d850a8ee6 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -225,16 +225,6 @@ int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
225ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, 225ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
226 void *buffer, size_t size); 226 void *buffer, size_t size);
227 227
228struct hdmi_vendor_infoframe {
229 enum hdmi_infoframe_type type;
230 unsigned char version;
231 unsigned char length;
232 u8 data[27];
233};
234
235ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
236 void *buffer, size_t size);
237
238enum hdmi_3d_structure { 228enum hdmi_3d_structure {
239 HDMI_3D_STRUCTURE_INVALID = -1, 229 HDMI_3D_STRUCTURE_INVALID = -1,
240 HDMI_3D_STRUCTURE_FRAME_PACKING = 0, 230 HDMI_3D_STRUCTURE_FRAME_PACKING = 0,
@@ -251,6 +241,7 @@ struct hdmi_hdmi_infoframe {
251 enum hdmi_infoframe_type type; 241 enum hdmi_infoframe_type type;
252 unsigned char version; 242 unsigned char version;
253 unsigned char length; 243 unsigned char length;
244 unsigned int oui;
254 u8 vic; 245 u8 vic;
255 enum hdmi_3d_structure s3d_struct; 246 enum hdmi_3d_structure s3d_struct;
256 unsigned int s3d_ext_data; 247 unsigned int s3d_ext_data;
@@ -260,12 +251,21 @@ int hdmi_hdmi_infoframe_init(struct hdmi_hdmi_infoframe *frame);
260ssize_t hdmi_hdmi_infoframe_pack(struct hdmi_hdmi_infoframe *frame, 251ssize_t hdmi_hdmi_infoframe_pack(struct hdmi_hdmi_infoframe *frame,
261 void *buffer, size_t size); 252 void *buffer, size_t size);
262 253
254union hdmi_vendor_infoframe {
255 struct {
256 enum hdmi_infoframe_type type;
257 unsigned char version;
258 unsigned char length;
259 unsigned int oui;
260 } any;
261 struct hdmi_hdmi_infoframe hdmi;
262};
263
263union hdmi_infoframe { 264union hdmi_infoframe {
264 struct hdmi_any_infoframe any; 265 struct hdmi_any_infoframe any;
265 struct hdmi_avi_infoframe avi; 266 struct hdmi_avi_infoframe avi;
266 struct hdmi_spd_infoframe spd; 267 struct hdmi_spd_infoframe spd;
267 struct hdmi_vendor_infoframe vendor; 268 union hdmi_vendor_infoframe vendor;
268 struct hdmi_hdmi_infoframe hdmi;
269 struct hdmi_audio_infoframe audio; 269 struct hdmi_audio_infoframe audio;
270}; 270};
271 271