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

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>

authored by

Lespiau, Damien and committed by
Dave Airlie
af3e95b4 c782d2e7

+22 -48
+10 -36
drivers/video/hdmi.c
··· 300 300 frame->type = HDMI_INFOFRAME_TYPE_VENDOR; 301 301 frame->version = 1; 302 302 303 + frame->oui = HDMI_IDENTIFIER; 304 + 303 305 /* 304 306 * 0 is a valid value for s3d_struct, so we use a special "not set" 305 307 * value ··· 379 377 } 380 378 EXPORT_SYMBOL(hdmi_hdmi_infoframe_pack); 381 379 382 - /** 383 - * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary 384 - * buffer 385 - * @frame: HDMI vendor infoframe 386 - * @buffer: destination buffer 387 - * @size: size of buffer 388 - * 389 - * Packs the information contained in the @frame structure into a binary 390 - * representation that can be written into the corresponding controller 391 - * registers. Also computes the checksum as required by section 5.3.5 of 392 - * the HDMI 1.4 specification. 393 - * 394 - * Returns the number of bytes packed into the binary buffer or a negative 395 - * error code on failure. 380 + /* 381 + * hdmi_vendor_infoframe_pack() - write a vendor infoframe to binary buffer 396 382 */ 397 - ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, 398 - void *buffer, size_t size) 383 + static ssize_t hdmi_vendor_infoframe_pack(union hdmi_vendor_infoframe *frame, 384 + void *buffer, size_t size) 399 385 { 400 - u8 *ptr = buffer; 401 - size_t length; 386 + /* we only know about HDMI vendor infoframes */ 387 + if (frame->any.oui != HDMI_IDENTIFIER) 388 + return -EINVAL; 402 389 403 - length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; 404 - 405 - if (size < length) 406 - return -ENOSPC; 407 - 408 - memset(buffer, 0, size); 409 - 410 - ptr[0] = frame->type; 411 - ptr[1] = frame->version; 412 - ptr[2] = frame->length; 413 - ptr[3] = 0; /* checksum */ 414 - 415 - memcpy(&ptr[HDMI_INFOFRAME_HEADER_SIZE], frame->data, frame->length); 416 - 417 - hdmi_infoframe_checksum(buffer, length); 418 - 419 - return length; 390 + return hdmi_hdmi_infoframe_pack(&frame->hdmi, buffer, size); 420 391 } 421 - EXPORT_SYMBOL(hdmi_vendor_infoframe_pack); 422 392 423 393 /** 424 394 * hdmi_infoframe_pack() - write a HDMI infoframe to binary buffer
+12 -12
include/linux/hdmi.h
··· 225 225 ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, 226 226 void *buffer, size_t size); 227 227 228 - struct hdmi_vendor_infoframe { 229 - enum hdmi_infoframe_type type; 230 - unsigned char version; 231 - unsigned char length; 232 - u8 data[27]; 233 - }; 234 - 235 - ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, 236 - void *buffer, size_t size); 237 - 238 228 enum hdmi_3d_structure { 239 229 HDMI_3D_STRUCTURE_INVALID = -1, 240 230 HDMI_3D_STRUCTURE_FRAME_PACKING = 0, ··· 241 251 enum hdmi_infoframe_type type; 242 252 unsigned char version; 243 253 unsigned char length; 254 + unsigned int oui; 244 255 u8 vic; 245 256 enum hdmi_3d_structure s3d_struct; 246 257 unsigned int s3d_ext_data; ··· 251 260 ssize_t hdmi_hdmi_infoframe_pack(struct hdmi_hdmi_infoframe *frame, 252 261 void *buffer, size_t size); 253 262 263 + union hdmi_vendor_infoframe { 264 + struct { 265 + enum hdmi_infoframe_type type; 266 + unsigned char version; 267 + unsigned char length; 268 + unsigned int oui; 269 + } any; 270 + struct hdmi_hdmi_infoframe hdmi; 271 + }; 272 + 254 273 union hdmi_infoframe { 255 274 struct hdmi_any_infoframe any; 256 275 struct hdmi_avi_infoframe avi; 257 276 struct hdmi_spd_infoframe spd; 258 - struct hdmi_vendor_infoframe vendor; 259 - struct hdmi_hdmi_infoframe hdmi; 277 + union hdmi_vendor_infoframe vendor; 260 278 struct hdmi_audio_infoframe audio; 261 279 }; 262 280