···5252 help5353 helper to get videomodes from the devicetree54545555+config HDMI5656+ bool5757+5558menuconfig FB5659 tristate "Support for frame buffer devices"5760 ---help---
+1
drivers/video/Makefile
···55# Each configuration option enables a list of files.6677obj-$(CONFIG_VGASTATE) += vgastate.o88+obj-$(CONFIG_HDMI) += hdmi.o89obj-y += fb_notify.o910obj-$(CONFIG_FB) += fb.o1011fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
+308
drivers/video/hdmi.c
···11+/*22+ * Copyright (C) 2012 Avionic Design GmbH33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License version 2 as66+ * published by the Free Software Foundation.77+ */88+99+#include <linux/bitops.h>1010+#include <linux/errno.h>1111+#include <linux/export.h>1212+#include <linux/hdmi.h>1313+#include <linux/string.h>1414+1515+static void hdmi_infoframe_checksum(void *buffer, size_t size)1616+{1717+ u8 *ptr = buffer;1818+ u8 csum = 0;1919+ size_t i;2020+2121+ /* compute checksum */2222+ for (i = 0; i < size; i++)2323+ csum += ptr[i];2424+2525+ ptr[3] = 256 - csum;2626+}2727+2828+/**2929+ * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe3030+ * @frame: HDMI AVI infoframe3131+ *3232+ * Returns 0 on success or a negative error code on failure.3333+ */3434+int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)3535+{3636+ memset(frame, 0, sizeof(*frame));3737+3838+ frame->type = HDMI_INFOFRAME_TYPE_AVI;3939+ frame->version = 2;4040+ frame->length = 13;4141+4242+ return 0;4343+}4444+EXPORT_SYMBOL(hdmi_avi_infoframe_init);4545+4646+/**4747+ * hdmi_avi_infoframe_pack() - write HDMI AVI infoframe to binary buffer4848+ * @frame: HDMI AVI infoframe4949+ * @buffer: destination buffer5050+ * @size: size of buffer5151+ *5252+ * Packs the information contained in the @frame structure into a binary5353+ * representation that can be written into the corresponding controller5454+ * registers. Also computes the checksum as required by section 5.3.5 of5555+ * the HDMI 1.4 specification.5656+ *5757+ * Returns the number of bytes packed into the binary buffer or a negative5858+ * error code on failure.5959+ */6060+ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,6161+ size_t size)6262+{6363+ u8 *ptr = buffer;6464+ size_t length;6565+6666+ length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;6767+6868+ if (size < length)6969+ return -ENOSPC;7070+7171+ memset(buffer, 0, length);7272+7373+ ptr[0] = frame->type;7474+ ptr[1] = frame->version;7575+ ptr[2] = frame->length;7676+ ptr[3] = 0; /* checksum */7777+7878+ /* start infoframe payload */7979+ ptr += HDMI_INFOFRAME_HEADER_SIZE;8080+8181+ ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3);8282+8383+ if (frame->active_info_valid)8484+ ptr[0] |= BIT(4);8585+8686+ if (frame->horizontal_bar_valid)8787+ ptr[0] |= BIT(3);8888+8989+ if (frame->vertical_bar_valid)9090+ ptr[0] |= BIT(2);9191+9292+ ptr[1] = ((frame->colorimetry & 0x3) << 6) |9393+ ((frame->picture_aspect & 0x3) << 4) |9494+ (frame->active_aspect & 0xf);9595+9696+ ptr[2] = ((frame->extended_colorimetry & 0x7) << 4) |9797+ ((frame->quantization_range & 0x3) << 2) |9898+ (frame->nups & 0x3);9999+100100+ if (frame->itc)101101+ ptr[2] |= BIT(7);102102+103103+ ptr[3] = frame->video_code & 0x7f;104104+105105+ ptr[4] = ((frame->ycc_quantization_range & 0x3) << 6) |106106+ ((frame->content_type & 0x3) << 4) |107107+ (frame->pixel_repeat & 0xf);108108+109109+ ptr[5] = frame->top_bar & 0xff;110110+ ptr[6] = (frame->top_bar >> 8) & 0xff;111111+ ptr[7] = frame->bottom_bar & 0xff;112112+ ptr[8] = (frame->bottom_bar >> 8) & 0xff;113113+ ptr[9] = frame->left_bar & 0xff;114114+ ptr[10] = (frame->left_bar >> 8) & 0xff;115115+ ptr[11] = frame->right_bar & 0xff;116116+ ptr[12] = (frame->right_bar >> 8) & 0xff;117117+118118+ hdmi_infoframe_checksum(buffer, length);119119+120120+ return length;121121+}122122+EXPORT_SYMBOL(hdmi_avi_infoframe_pack);123123+124124+/**125125+ * hdmi_spd_infoframe_init() - initialize an HDMI SPD infoframe126126+ * @frame: HDMI SPD infoframe127127+ * @vendor: vendor string128128+ * @product: product string129129+ *130130+ * Returns 0 on success or a negative error code on failure.131131+ */132132+int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,133133+ const char *vendor, const char *product)134134+{135135+ memset(frame, 0, sizeof(*frame));136136+137137+ frame->type = HDMI_INFOFRAME_TYPE_SPD;138138+ frame->version = 1;139139+ frame->length = 25;140140+141141+ strncpy(frame->vendor, vendor, sizeof(frame->vendor));142142+ strncpy(frame->product, product, sizeof(frame->product));143143+144144+ return 0;145145+}146146+EXPORT_SYMBOL(hdmi_spd_infoframe_init);147147+148148+/**149149+ * hdmi_spd_infoframe_pack() - write HDMI SPD infoframe to binary buffer150150+ * @frame: HDMI SPD infoframe151151+ * @buffer: destination buffer152152+ * @size: size of buffer153153+ *154154+ * Packs the information contained in the @frame structure into a binary155155+ * representation that can be written into the corresponding controller156156+ * registers. Also computes the checksum as required by section 5.3.5 of157157+ * the HDMI 1.4 specification.158158+ *159159+ * Returns the number of bytes packed into the binary buffer or a negative160160+ * error code on failure.161161+ */162162+ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,163163+ size_t size)164164+{165165+ u8 *ptr = buffer;166166+ size_t length;167167+168168+ length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;169169+170170+ if (size < length)171171+ return -ENOSPC;172172+173173+ memset(buffer, 0, length);174174+175175+ ptr[0] = frame->type;176176+ ptr[1] = frame->version;177177+ ptr[2] = frame->length;178178+ ptr[3] = 0; /* checksum */179179+180180+ /* start infoframe payload */181181+ ptr += HDMI_INFOFRAME_HEADER_SIZE;182182+183183+ memcpy(ptr, frame->vendor, sizeof(frame->vendor));184184+ memcpy(ptr + 8, frame->product, sizeof(frame->product));185185+186186+ ptr[24] = frame->sdi;187187+188188+ hdmi_infoframe_checksum(buffer, length);189189+190190+ return length;191191+}192192+EXPORT_SYMBOL(hdmi_spd_infoframe_pack);193193+194194+/**195195+ * hdmi_audio_infoframe_init() - initialize an HDMI audio infoframe196196+ * @frame: HDMI audio infoframe197197+ *198198+ * Returns 0 on success or a negative error code on failure.199199+ */200200+int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame)201201+{202202+ memset(frame, 0, sizeof(*frame));203203+204204+ frame->type = HDMI_INFOFRAME_TYPE_AUDIO;205205+ frame->version = 1;206206+ frame->length = 10;207207+208208+ return 0;209209+}210210+EXPORT_SYMBOL(hdmi_audio_infoframe_init);211211+212212+/**213213+ * hdmi_audio_infoframe_pack() - write HDMI audio infoframe to binary buffer214214+ * @frame: HDMI audio infoframe215215+ * @buffer: destination buffer216216+ * @size: size of buffer217217+ *218218+ * Packs the information contained in the @frame structure into a binary219219+ * representation that can be written into the corresponding controller220220+ * registers. Also computes the checksum as required by section 5.3.5 of221221+ * the HDMI 1.4 specification.222222+ *223223+ * Returns the number of bytes packed into the binary buffer or a negative224224+ * error code on failure.225225+ */226226+ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,227227+ void *buffer, size_t size)228228+{229229+ unsigned char channels;230230+ u8 *ptr = buffer;231231+ size_t length;232232+233233+ length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;234234+235235+ if (size < length)236236+ return -ENOSPC;237237+238238+ memset(buffer, 0, length);239239+240240+ if (frame->channels >= 2)241241+ channels = frame->channels - 1;242242+ else243243+ channels = 0;244244+245245+ ptr[0] = frame->type;246246+ ptr[1] = frame->version;247247+ ptr[2] = frame->length;248248+ ptr[3] = 0; /* checksum */249249+250250+ /* start infoframe payload */251251+ ptr += HDMI_INFOFRAME_HEADER_SIZE;252252+253253+ ptr[0] = ((frame->coding_type & 0xf) << 4) | (channels & 0x7);254254+ ptr[1] = ((frame->sample_frequency & 0x7) << 2) |255255+ (frame->sample_size & 0x3);256256+ ptr[2] = frame->coding_type_ext & 0x1f;257257+ ptr[3] = frame->channel_allocation;258258+ ptr[4] = (frame->level_shift_value & 0xf) << 3;259259+260260+ if (frame->downmix_inhibit)261261+ ptr[4] |= BIT(7);262262+263263+ hdmi_infoframe_checksum(buffer, length);264264+265265+ return length;266266+}267267+EXPORT_SYMBOL(hdmi_audio_infoframe_pack);268268+269269+/**270270+ * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary271271+ * buffer272272+ * @frame: HDMI vendor infoframe273273+ * @buffer: destination buffer274274+ * @size: size of buffer275275+ *276276+ * Packs the information contained in the @frame structure into a binary277277+ * representation that can be written into the corresponding controller278278+ * registers. Also computes the checksum as required by section 5.3.5 of279279+ * the HDMI 1.4 specification.280280+ *281281+ * Returns the number of bytes packed into the binary buffer or a negative282282+ * error code on failure.283283+ */284284+ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,285285+ void *buffer, size_t size)286286+{287287+ u8 *ptr = buffer;288288+ size_t length;289289+290290+ length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;291291+292292+ if (size < length)293293+ return -ENOSPC;294294+295295+ memset(buffer, 0, length);296296+297297+ ptr[0] = frame->type;298298+ ptr[1] = frame->version;299299+ ptr[2] = frame->length;300300+ ptr[3] = 0; /* checksum */301301+302302+ memcpy(&ptr[HDMI_INFOFRAME_HEADER_SIZE], frame->data, frame->length);303303+304304+ hdmi_infoframe_checksum(buffer, length);305305+306306+ return length;307307+}308308+EXPORT_SYMBOL(hdmi_vendor_infoframe_pack);