diff options
author | Martin Bugge <marbugge@cisco.com> | 2014-12-19 07:14:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-01-27 07:19:48 -0500 |
commit | 09f90c53acab944de89c3ad48a75e2b64f3211e3 (patch) | |
tree | bf06ab50bfa8e2b3de411f9c09b20d7bf7db5398 /drivers/media | |
parent | dc189053e1a5ae606c56e432dae1afc28261a819 (diff) |
[media] adv7842: simplify InfoFrame logging
Use the new logging functions from the hdmi module.
Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/i2c/Kconfig | 1 | ||||
-rw-r--r-- | drivers/media/i2c/adv7842.c | 174 |
2 files changed, 47 insertions, 128 deletions
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index ca84543cf6ac..0828b6b28fa4 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig | |||
@@ -209,6 +209,7 @@ config VIDEO_ADV7604 | |||
209 | config VIDEO_ADV7842 | 209 | config VIDEO_ADV7842 |
210 | tristate "Analog Devices ADV7842 decoder" | 210 | tristate "Analog Devices ADV7842 decoder" |
211 | depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API | 211 | depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API |
212 | select HDMI | ||
212 | ---help--- | 213 | ---help--- |
213 | Support for the Analog Devices ADV7842 video decoder. | 214 | Support for the Analog Devices ADV7842 video decoder. |
214 | 215 | ||
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 6bc872d43717..7c215ee142c4 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/videodev2.h> | 38 | #include <linux/videodev2.h> |
39 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
40 | #include <linux/v4l2-dv-timings.h> | 40 | #include <linux/v4l2-dv-timings.h> |
41 | #include <linux/hdmi.h> | ||
41 | #include <media/v4l2-device.h> | 42 | #include <media/v4l2-device.h> |
42 | #include <media/v4l2-ctrls.h> | 43 | #include <media/v4l2-ctrls.h> |
43 | #include <media/v4l2-dv-timings.h> | 44 | #include <media/v4l2-dv-timings.h> |
@@ -2098,149 +2099,65 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e) | |||
2098 | return err; | 2099 | return err; |
2099 | } | 2100 | } |
2100 | 2101 | ||
2101 | /*********** avi info frame CEA-861-E **************/ | 2102 | struct adv7842_cfg_read_infoframe { |
2102 | /* TODO move to common library */ | 2103 | const char *desc; |
2103 | 2104 | u8 present_mask; | |
2104 | struct avi_info_frame { | 2105 | u8 head_addr; |
2105 | uint8_t f17; | 2106 | u8 payload_addr; |
2106 | uint8_t y10; | ||
2107 | uint8_t a0; | ||
2108 | uint8_t b10; | ||
2109 | uint8_t s10; | ||
2110 | uint8_t c10; | ||
2111 | uint8_t m10; | ||
2112 | uint8_t r3210; | ||
2113 | uint8_t itc; | ||
2114 | uint8_t ec210; | ||
2115 | uint8_t q10; | ||
2116 | uint8_t sc10; | ||
2117 | uint8_t f47; | ||
2118 | uint8_t vic; | ||
2119 | uint8_t yq10; | ||
2120 | uint8_t cn10; | ||
2121 | uint8_t pr3210; | ||
2122 | uint16_t etb; | ||
2123 | uint16_t sbb; | ||
2124 | uint16_t elb; | ||
2125 | uint16_t srb; | ||
2126 | }; | 2107 | }; |
2127 | 2108 | ||
2128 | static const char *y10_txt[4] = { | 2109 | static void log_infoframe(struct v4l2_subdev *sd, struct adv7842_cfg_read_infoframe *cri) |
2129 | "RGB", | ||
2130 | "YCbCr 4:2:2", | ||
2131 | "YCbCr 4:4:4", | ||
2132 | "Future", | ||
2133 | }; | ||
2134 | |||
2135 | static const char *c10_txt[4] = { | ||
2136 | "No Data", | ||
2137 | "SMPTE 170M", | ||
2138 | "ITU-R 709", | ||
2139 | "Extended Colorimetry information valied", | ||
2140 | }; | ||
2141 | |||
2142 | static const char *itc_txt[2] = { | ||
2143 | "No Data", | ||
2144 | "IT content", | ||
2145 | }; | ||
2146 | |||
2147 | static const char *ec210_txt[8] = { | ||
2148 | "xvYCC601", | ||
2149 | "xvYCC709", | ||
2150 | "sYCC601", | ||
2151 | "AdobeYCC601", | ||
2152 | "AdobeRGB", | ||
2153 | "5 reserved", | ||
2154 | "6 reserved", | ||
2155 | "7 reserved", | ||
2156 | }; | ||
2157 | |||
2158 | static const char *q10_txt[4] = { | ||
2159 | "Default", | ||
2160 | "Limited Range", | ||
2161 | "Full Range", | ||
2162 | "Reserved", | ||
2163 | }; | ||
2164 | |||
2165 | static void parse_avi_infoframe(struct v4l2_subdev *sd, uint8_t *buf, | ||
2166 | struct avi_info_frame *avi) | ||
2167 | { | ||
2168 | avi->f17 = (buf[1] >> 7) & 0x1; | ||
2169 | avi->y10 = (buf[1] >> 5) & 0x3; | ||
2170 | avi->a0 = (buf[1] >> 4) & 0x1; | ||
2171 | avi->b10 = (buf[1] >> 2) & 0x3; | ||
2172 | avi->s10 = buf[1] & 0x3; | ||
2173 | avi->c10 = (buf[2] >> 6) & 0x3; | ||
2174 | avi->m10 = (buf[2] >> 4) & 0x3; | ||
2175 | avi->r3210 = buf[2] & 0xf; | ||
2176 | avi->itc = (buf[3] >> 7) & 0x1; | ||
2177 | avi->ec210 = (buf[3] >> 4) & 0x7; | ||
2178 | avi->q10 = (buf[3] >> 2) & 0x3; | ||
2179 | avi->sc10 = buf[3] & 0x3; | ||
2180 | avi->f47 = (buf[4] >> 7) & 0x1; | ||
2181 | avi->vic = buf[4] & 0x7f; | ||
2182 | avi->yq10 = (buf[5] >> 6) & 0x3; | ||
2183 | avi->cn10 = (buf[5] >> 4) & 0x3; | ||
2184 | avi->pr3210 = buf[5] & 0xf; | ||
2185 | avi->etb = buf[6] + 256*buf[7]; | ||
2186 | avi->sbb = buf[8] + 256*buf[9]; | ||
2187 | avi->elb = buf[10] + 256*buf[11]; | ||
2188 | avi->srb = buf[12] + 256*buf[13]; | ||
2189 | } | ||
2190 | |||
2191 | static void print_avi_infoframe(struct v4l2_subdev *sd) | ||
2192 | { | 2110 | { |
2193 | int i; | 2111 | int i; |
2194 | uint8_t buf[14]; | 2112 | uint8_t buffer[32]; |
2195 | u8 avi_len; | 2113 | union hdmi_infoframe frame; |
2196 | u8 avi_ver; | 2114 | u8 len; |
2197 | struct avi_info_frame avi; | 2115 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
2116 | struct device *dev = &client->dev; | ||
2198 | 2117 | ||
2199 | if (!(hdmi_read(sd, 0x05) & 0x80)) { | 2118 | if (!(io_read(sd, 0x60) & cri->present_mask)) { |
2200 | v4l2_info(sd, "receive DVI-D signal (AVI infoframe not supported)\n"); | 2119 | v4l2_info(sd, "%s infoframe not received\n", cri->desc); |
2201 | return; | ||
2202 | } | ||
2203 | if (!(io_read(sd, 0x60) & 0x01)) { | ||
2204 | v4l2_info(sd, "AVI infoframe not received\n"); | ||
2205 | return; | 2120 | return; |
2206 | } | 2121 | } |
2207 | 2122 | ||
2208 | if (io_read(sd, 0x88) & 0x10) { | 2123 | for (i = 0; i < 3; i++) |
2209 | v4l2_info(sd, "AVI infoframe checksum error has occurred earlier\n"); | 2124 | buffer[i] = infoframe_read(sd, cri->head_addr + i); |
2210 | io_write(sd, 0x8a, 0x10); /* clear AVI_INF_CKS_ERR_RAW */ | ||
2211 | if (io_read(sd, 0x88) & 0x10) { | ||
2212 | v4l2_info(sd, "AVI infoframe checksum error still present\n"); | ||
2213 | io_write(sd, 0x8a, 0x10); /* clear AVI_INF_CKS_ERR_RAW */ | ||
2214 | } | ||
2215 | } | ||
2216 | 2125 | ||
2217 | avi_len = infoframe_read(sd, 0xe2); | 2126 | len = buffer[2] + 1; |
2218 | avi_ver = infoframe_read(sd, 0xe1); | ||
2219 | v4l2_info(sd, "AVI infoframe version %d (%d byte)\n", | ||
2220 | avi_ver, avi_len); | ||
2221 | 2127 | ||
2222 | if (avi_ver != 0x02) | 2128 | if (len + 3 > sizeof(buffer)) { |
2129 | v4l2_err(sd, "%s: invalid %s infoframe length %d\n", __func__, cri->desc, len); | ||
2223 | return; | 2130 | return; |
2131 | } | ||
2224 | 2132 | ||
2225 | for (i = 0; i < 14; i++) | 2133 | for (i = 0; i < len; i++) |
2226 | buf[i] = infoframe_read(sd, i); | 2134 | buffer[i + 3] = infoframe_read(sd, cri->payload_addr + i); |
2227 | 2135 | ||
2228 | v4l2_info(sd, "\t%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | 2136 | if (hdmi_infoframe_unpack(&frame, buffer) < 0) { |
2229 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], | 2137 | v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc); |
2230 | buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]); | 2138 | return; |
2139 | } | ||
2231 | 2140 | ||
2232 | parse_avi_infoframe(sd, buf, &avi); | 2141 | hdmi_infoframe_log(KERN_INFO, dev, &frame); |
2142 | } | ||
2233 | 2143 | ||
2234 | if (avi.vic) | 2144 | static void adv7842_log_infoframes(struct v4l2_subdev *sd) |
2235 | v4l2_info(sd, "\tVIC: %d\n", avi.vic); | 2145 | { |
2236 | if (avi.itc) | 2146 | int i; |
2237 | v4l2_info(sd, "\t%s\n", itc_txt[avi.itc]); | 2147 | struct adv7842_cfg_read_infoframe cri[] = { |
2148 | { "AVI", 0x01, 0xe0, 0x00 }, | ||
2149 | { "Audio", 0x02, 0xe3, 0x1c }, | ||
2150 | { "SDP", 0x04, 0xe6, 0x2a }, | ||
2151 | { "Vendor", 0x10, 0xec, 0x54 } | ||
2152 | }; | ||
2238 | 2153 | ||
2239 | if (avi.y10) | 2154 | if (!(hdmi_read(sd, 0x05) & 0x80)) { |
2240 | v4l2_info(sd, "\t%s %s\n", y10_txt[avi.y10], !avi.c10 ? "" : | 2155 | v4l2_info(sd, "receive DVI-D signal, no infoframes\n"); |
2241 | (avi.c10 == 0x3 ? ec210_txt[avi.ec210] : c10_txt[avi.c10])); | 2156 | return; |
2242 | else | 2157 | } |
2243 | v4l2_info(sd, "\t%s %s\n", y10_txt[avi.y10], q10_txt[avi.q10]); | 2158 | |
2159 | for (i = 0; i < ARRAY_SIZE(cri); i++) | ||
2160 | log_infoframe(sd, &cri[i]); | ||
2244 | } | 2161 | } |
2245 | 2162 | ||
2246 | static const char * const prim_mode_txt[] = { | 2163 | static const char * const prim_mode_txt[] = { |
@@ -2454,7 +2371,8 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd) | |||
2454 | v4l2_info(sd, "Deep color mode: %s\n", | 2371 | v4l2_info(sd, "Deep color mode: %s\n", |
2455 | deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]); | 2372 | deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]); |
2456 | 2373 | ||
2457 | print_avi_infoframe(sd); | 2374 | adv7842_log_infoframes(sd); |
2375 | |||
2458 | return 0; | 2376 | return 0; |
2459 | } | 2377 | } |
2460 | 2378 | ||