Lines Matching +full:capture +full:- +full:sd +full:- +full:lines

1 // SPDX-License-Identifier: GPL-2.0
16 #include <linux/v4l2-dv-timings.h>
19 #include <media/v4l2-ctrls.h>
20 #include <media/v4l2-device.h>
21 #include <media/v4l2-dv-timings.h>
22 #include <media/v4l2-event.h>
23 #include <media/v4l2-fwnode.h>
31 #include <dt-bindings/media/tda1997x.h>
40 MODULE_PARM_DESC(debug, "debug level (0-2)");
46 "OBA", /* One-Bit Audio */
71 "Full Range (0-255)",
72 "Limited Range (16-235)",
78 "YUV422 semi-planar", /* YUV422 16bit data base, 8bpp */
121 "YUV709 -> RGB full",
122 -256, -2048, -2048,
123 4769, -2183, -873,
129 "YUV601 -> RGB full",
130 -256, -2048, -2048,
131 4769, -3330, -1602,
137 "RGB limited -> RGB full",
138 -256, -256, -256,
145 "RGB limited -> ITU601",
146 -256, -256, -256,
148 -1754, 2095, -341,
149 -1388, -707, 2095,
153 "RGB limited -> ITU709",
154 -256, -256, -256,
156 -1894, 2087, -190,
157 -1607, -477, 2087,
161 "RGB full -> ITU601",
164 -1506, 1799, -293,
165 -1192, -607, 1799,
169 "RGB full -> ITU709",
172 -1627, 1792, -163,
173 -1380, -410, 1792,
226 struct v4l2_subdev sd; member
296 static inline struct tda1997x_state *to_state(struct v4l2_subdev *sd) in to_state() argument
298 return container_of(sd, struct tda1997x_state, sd); in to_state()
303 return &container_of(ctrl->handler, struct tda1997x_state, hdl)->sd; in to_sd()
306 static int tda1997x_cec_read(struct v4l2_subdev *sd, u8 reg) in tda1997x_cec_read() argument
308 struct tda1997x_state *state = to_state(sd); in tda1997x_cec_read()
311 val = i2c_smbus_read_byte_data(state->client_cec, reg); in tda1997x_cec_read()
313 v4l_err(state->client, "read reg error: reg=%2x\n", reg); in tda1997x_cec_read()
314 val = -1; in tda1997x_cec_read()
320 static int tda1997x_cec_write(struct v4l2_subdev *sd, u8 reg, u8 val) in tda1997x_cec_write() argument
322 struct tda1997x_state *state = to_state(sd); in tda1997x_cec_write()
325 ret = i2c_smbus_write_byte_data(state->client_cec, reg, val); in tda1997x_cec_write()
327 v4l_err(state->client, "write reg error:reg=%2x,val=%2x\n", in tda1997x_cec_write()
329 ret = -1; in tda1997x_cec_write()
335 /* -----------------------------------------------------------------------------
339 static int tda1997x_setpage(struct v4l2_subdev *sd, u8 page) in tda1997x_setpage() argument
341 struct tda1997x_state *state = to_state(sd); in tda1997x_setpage()
344 if (state->page != page) { in tda1997x_setpage()
345 ret = i2c_smbus_write_byte_data(state->client, in tda1997x_setpage()
348 v4l_err(state->client, in tda1997x_setpage()
353 state->page = page; in tda1997x_setpage()
358 static inline int io_read(struct v4l2_subdev *sd, u16 reg) in io_read() argument
360 struct tda1997x_state *state = to_state(sd); in io_read()
363 mutex_lock(&state->page_lock); in io_read()
364 if (tda1997x_setpage(sd, reg >> 8)) { in io_read()
365 val = -1; in io_read()
369 val = i2c_smbus_read_byte_data(state->client, reg&0xff); in io_read()
371 v4l_err(state->client, "read reg error: reg=%2x\n", reg & 0xff); in io_read()
372 val = -1; in io_read()
377 mutex_unlock(&state->page_lock); in io_read()
381 static inline long io_read16(struct v4l2_subdev *sd, u16 reg) in io_read16() argument
386 val = io_read(sd, reg); in io_read16()
390 val = io_read(sd, reg + 1); in io_read16()
398 static inline long io_read24(struct v4l2_subdev *sd, u16 reg) in io_read24() argument
403 val = io_read(sd, reg); in io_read24()
407 val = io_read(sd, reg + 1); in io_read24()
411 val = io_read(sd, reg + 2); in io_read24()
419 static unsigned int io_readn(struct v4l2_subdev *sd, u16 reg, u8 len, u8 *data) in io_readn() argument
426 val = io_read(sd, reg + i); in io_readn()
436 static int io_write(struct v4l2_subdev *sd, u16 reg, u8 val) in io_write() argument
438 struct tda1997x_state *state = to_state(sd); in io_write()
441 mutex_lock(&state->page_lock); in io_write()
442 if (tda1997x_setpage(sd, reg >> 8)) { in io_write()
443 ret = -1; in io_write()
447 ret = i2c_smbus_write_byte_data(state->client, reg & 0xff, val); in io_write()
449 v4l_err(state->client, "write reg error:reg=%2x,val=%2x\n", in io_write()
451 ret = -1; in io_write()
456 mutex_unlock(&state->page_lock); in io_write()
460 static int io_write16(struct v4l2_subdev *sd, u16 reg, u16 val) in io_write16() argument
464 ret = io_write(sd, reg, (val >> 8) & 0xff); in io_write16()
467 ret = io_write(sd, reg + 1, val & 0xff); in io_write16()
473 static int io_write24(struct v4l2_subdev *sd, u16 reg, u32 val) in io_write24() argument
477 ret = io_write(sd, reg, (val >> 16) & 0xff); in io_write24()
480 ret = io_write(sd, reg + 1, (val >> 8) & 0xff); in io_write24()
483 ret = io_write(sd, reg + 2, val & 0xff); in io_write24()
489 /* -----------------------------------------------------------------------------
502 static int tda1997x_manual_hpd(struct v4l2_subdev *sd, enum hpd_mode mode) in tda1997x_manual_hpd() argument
506 hpd_auto = io_read(sd, REG_HPD_AUTO_CTRL); in tda1997x_manual_hpd()
507 hpd_pwr = io_read(sd, REG_HPD_POWER); in tda1997x_manual_hpd()
508 hpd_man = io_read(sd, REG_HPD_MAN_CTRL); in tda1997x_manual_hpd()
523 io_write(sd, REG_HPD_POWER, hpd_pwr); in tda1997x_manual_hpd()
524 io_write(sd, REG_HPD_MAN_CTRL, hpd_man); in tda1997x_manual_hpd()
531 io_write(sd, REG_HPD_POWER, hpd_pwr); in tda1997x_manual_hpd()
539 io_write(sd, REG_HPD_AUTO_CTRL, hpd_auto); in tda1997x_manual_hpd()
540 io_write(sd, REG_HPD_MAN_CTRL, hpd_man); in tda1997x_manual_hpd()
545 io_write(sd, REG_HPD_AUTO_CTRL, hpd_auto); in tda1997x_manual_hpd()
551 io_write(sd, REG_HPD_MAN_CTRL, hpd_man); in tda1997x_manual_hpd()
564 struct v4l2_subdev *sd = &state->sd; in tda1997x_delayed_work_enable_hpd() local
566 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tda1997x_delayed_work_enable_hpd()
569 tda1997x_manual_hpd(sd, HPD_HIGH_OTHER); in tda1997x_delayed_work_enable_hpd()
570 tda1997x_manual_hpd(sd, HPD_HIGH_BP); in tda1997x_delayed_work_enable_hpd()
572 state->edid.present = 1; in tda1997x_delayed_work_enable_hpd()
575 static void tda1997x_disable_edid(struct v4l2_subdev *sd) in tda1997x_disable_edid() argument
577 struct tda1997x_state *state = to_state(sd); in tda1997x_disable_edid()
579 v4l2_dbg(1, debug, sd, "%s\n", __func__); in tda1997x_disable_edid()
580 cancel_delayed_work_sync(&state->delayed_work_enable_hpd); in tda1997x_disable_edid()
583 tda1997x_manual_hpd(sd, HPD_LOW_BP); in tda1997x_disable_edid()
586 static void tda1997x_enable_edid(struct v4l2_subdev *sd) in tda1997x_enable_edid() argument
588 struct tda1997x_state *state = to_state(sd); in tda1997x_enable_edid()
590 v4l2_dbg(1, debug, sd, "%s\n", __func__); in tda1997x_enable_edid()
593 schedule_delayed_work(&state->delayed_work_enable_hpd, HZ / 10); in tda1997x_enable_edid()
596 /* -----------------------------------------------------------------------------
606 v4l_dbg(1, debug, state->client, "%s code=0x%x\n", __func__, code); in tda1997x_setup_format()
612 state->vid_fmt = OF_FMT_444; in tda1997x_setup_format()
617 state->vid_fmt = OF_FMT_422_SMPT; in tda1997x_setup_format()
622 state->vid_fmt = OF_FMT_422_CCIR; in tda1997x_setup_format()
625 v4l_err(state->client, "incompatible format (0x%x)\n", code); in tda1997x_setup_format()
626 return -EINVAL; in tda1997x_setup_format()
628 v4l_dbg(1, debug, state->client, "%s code=0x%x fmt=%s\n", __func__, in tda1997x_setup_format()
629 code, vidfmt_names[state->vid_fmt]); in tda1997x_setup_format()
630 state->mbus_code = code; in tda1997x_setup_format()
638 * full-range and YUV is to be limited range.
640 * RGB full-range uses values from 0 to 255 which is recommended on a monitor
645 tda1997x_configure_csc(struct v4l2_subdev *sd) in tda1997x_configure_csc() argument
647 struct tda1997x_state *state = to_state(sd); in tda1997x_configure_csc()
648 struct hdmi_avi_infoframe *avi = &state->avi_infoframe; in tda1997x_configure_csc()
649 struct v4l2_hdmi_colorimetry *c = &state->colorimetry; in tda1997x_configure_csc()
661 v4l_dbg(1, debug, state->client, "input:%s quant:%s output:%s\n", in tda1997x_configure_csc()
662 hdmi_colorspace_names[avi->colorspace], in tda1997x_configure_csc()
663 v4l2_quantization_names[c->quantization], in tda1997x_configure_csc()
664 vidfmt_names[state->vid_fmt]); in tda1997x_configure_csc()
665 state->conv = NULL; in tda1997x_configure_csc()
666 switch (state->vid_fmt) { in tda1997x_configure_csc()
670 if (c->colorspace == V4L2_COLORSPACE_SRGB) { in tda1997x_configure_csc()
671 if (c->quantization == V4L2_QUANTIZATION_LIM_RANGE) in tda1997x_configure_csc()
672 state->conv = &conv_matrix[RGBLIMITED_RGBFULL]; in tda1997x_configure_csc()
674 if (c->colorspace == V4L2_COLORSPACE_REC709) in tda1997x_configure_csc()
675 state->conv = &conv_matrix[ITU709_RGBFULL]; in tda1997x_configure_csc()
676 else if (c->colorspace == V4L2_COLORSPACE_SMPTE170M) in tda1997x_configure_csc()
677 state->conv = &conv_matrix[ITU601_RGBFULL]; in tda1997x_configure_csc()
682 case OF_FMT_422_SMPT: /* semi-planar */ in tda1997x_configure_csc()
685 if ((c->colorspace == V4L2_COLORSPACE_SRGB) && in tda1997x_configure_csc()
686 (c->quantization == V4L2_QUANTIZATION_FULL_RANGE)) { in tda1997x_configure_csc()
687 if (state->timings.bt.height <= 576) in tda1997x_configure_csc()
688 state->conv = &conv_matrix[RGBFULL_ITU601]; in tda1997x_configure_csc()
690 state->conv = &conv_matrix[RGBFULL_ITU709]; in tda1997x_configure_csc()
691 } else if ((c->colorspace == V4L2_COLORSPACE_SRGB) && in tda1997x_configure_csc()
692 (c->quantization == V4L2_QUANTIZATION_LIM_RANGE)) { in tda1997x_configure_csc()
693 if (state->timings.bt.height <= 576) in tda1997x_configure_csc()
694 state->conv = &conv_matrix[RGBLIMITED_ITU601]; in tda1997x_configure_csc()
696 state->conv = &conv_matrix[RGBLIMITED_ITU709]; in tda1997x_configure_csc()
701 if (state->conv) { in tda1997x_configure_csc()
702 v4l_dbg(1, debug, state->client, "%s\n", in tda1997x_configure_csc()
703 state->conv->name); in tda1997x_configure_csc()
705 reg = io_read(sd, REG_VDP_CTRL); in tda1997x_configure_csc()
707 io_write(sd, REG_VDP_CTRL, reg); in tda1997x_configure_csc()
709 io_write16(sd, REG_VDP_MATRIX + 0, state->conv->offint1); in tda1997x_configure_csc()
710 io_write16(sd, REG_VDP_MATRIX + 2, state->conv->offint2); in tda1997x_configure_csc()
711 io_write16(sd, REG_VDP_MATRIX + 4, state->conv->offint3); in tda1997x_configure_csc()
713 io_write16(sd, REG_VDP_MATRIX + 6, state->conv->p11coef); in tda1997x_configure_csc()
714 io_write16(sd, REG_VDP_MATRIX + 8, state->conv->p12coef); in tda1997x_configure_csc()
715 io_write16(sd, REG_VDP_MATRIX + 10, state->conv->p13coef); in tda1997x_configure_csc()
716 io_write16(sd, REG_VDP_MATRIX + 12, state->conv->p21coef); in tda1997x_configure_csc()
717 io_write16(sd, REG_VDP_MATRIX + 14, state->conv->p22coef); in tda1997x_configure_csc()
718 io_write16(sd, REG_VDP_MATRIX + 16, state->conv->p23coef); in tda1997x_configure_csc()
719 io_write16(sd, REG_VDP_MATRIX + 18, state->conv->p31coef); in tda1997x_configure_csc()
720 io_write16(sd, REG_VDP_MATRIX + 20, state->conv->p32coef); in tda1997x_configure_csc()
721 io_write16(sd, REG_VDP_MATRIX + 22, state->conv->p33coef); in tda1997x_configure_csc()
723 io_write16(sd, REG_VDP_MATRIX + 24, state->conv->offout1); in tda1997x_configure_csc()
724 io_write16(sd, REG_VDP_MATRIX + 26, state->conv->offout2); in tda1997x_configure_csc()
725 io_write16(sd, REG_VDP_MATRIX + 28, state->conv->offout3); in tda1997x_configure_csc()
728 reg = io_read(sd, REG_VDP_CTRL); in tda1997x_configure_csc()
730 io_write(sd, REG_VDP_CTRL, reg); in tda1997x_configure_csc()
735 io_write16(sd, REG_BLK_GY, blanking_codes->code_gy); in tda1997x_configure_csc()
736 io_write16(sd, REG_BLK_BU, blanking_codes->code_bu); in tda1997x_configure_csc()
737 io_write16(sd, REG_BLK_RV, blanking_codes->code_rv); in tda1997x_configure_csc()
743 tda1997x_configure_vhref(struct v4l2_subdev *sd) in tda1997x_configure_vhref() argument
745 struct tda1997x_state *state = to_state(sd); in tda1997x_configure_vhref()
746 const struct v4l2_bt_timings *bt = &state->timings.bt; in tda1997x_configure_vhref()
747 int width, lines; in tda1997x_configure_vhref() local
755 href_start = bt->hbackporch + bt->hsync + 1; in tda1997x_configure_vhref()
756 href_end = href_start + bt->width; in tda1997x_configure_vhref()
757 vref_f1_start = bt->height + bt->vbackporch + bt->vsync + in tda1997x_configure_vhref()
758 bt->il_vbackporch + bt->il_vsync + in tda1997x_configure_vhref()
759 bt->il_vfrontporch; in tda1997x_configure_vhref()
760 vref_f1_width = bt->vbackporch + bt->vsync + bt->vfrontporch; in tda1997x_configure_vhref()
765 if (bt->interlaced) { in tda1997x_configure_vhref()
766 vref_f2_start = (bt->height / 2) + in tda1997x_configure_vhref()
767 (bt->il_vbackporch + bt->il_vsync - 1); in tda1997x_configure_vhref()
768 vref_f2_width = bt->il_vbackporch + bt->il_vsync + in tda1997x_configure_vhref()
769 bt->il_vfrontporch; in tda1997x_configure_vhref()
770 fieldref_f2_start = vref_f2_start + bt->il_vfrontporch + in tda1997x_configure_vhref()
776 lines = V4L2_DV_BT_FRAME_HEIGHT(bt); in tda1997x_configure_vhref()
782 io_write16(sd, REG_FDW_S, 0x2ef); /* start position */ in tda1997x_configure_vhref()
783 io_write16(sd, REG_FDW_E, 0x141); /* end position */ in tda1997x_configure_vhref()
786 if (state->chip_revision == 0) in tda1997x_configure_vhref()
787 io_write16(sd, REG_PXCNT_PR, 4); in tda1997x_configure_vhref()
789 io_write16(sd, REG_PXCNT_PR, 1); in tda1997x_configure_vhref()
790 io_write16(sd, REG_PXCNT_NPIX, width & MASK_VHREF); in tda1997x_configure_vhref()
791 io_write16(sd, REG_LCNT_PR, 1); in tda1997x_configure_vhref()
792 io_write16(sd, REG_LCNT_NLIN, lines & MASK_VHREF); in tda1997x_configure_vhref()
800 io_write(sd, REG_VHREF_CTRL, reg); in tda1997x_configure_vhref()
805 * horiz and vert ref values (non-active pixel areas) of the generator in tda1997x_configure_vhref()
809 io_write16(sd, REG_HREF_S, href_start & MASK_VHREF); in tda1997x_configure_vhref()
810 io_write16(sd, REG_HREF_E, href_end & MASK_VHREF); in tda1997x_configure_vhref()
812 io_write16(sd, REG_VREF_F1_S, vref_f1_start & MASK_VHREF); in tda1997x_configure_vhref()
813 io_write(sd, REG_VREF_F1_WIDTH, vref_f1_width); in tda1997x_configure_vhref()
815 io_write16(sd, REG_VREF_F2_S, vref_f2_start & MASK_VHREF); in tda1997x_configure_vhref()
816 io_write(sd, REG_VREF_F2_WIDTH, vref_f2_width); in tda1997x_configure_vhref()
821 io_write16(sd, REG_FREF_F1_S, reg); in tda1997x_configure_vhref()
823 io_write16(sd, REG_FREF_F2_S, reg); in tda1997x_configure_vhref()
830 struct v4l2_subdev *sd = &state->sd; in tda1997x_configure_vidout() local
831 struct tda1997x_platform_data *pdata = &state->pdata; in tda1997x_configure_vidout()
836 reg = (state->vid_fmt == OF_FMT_422_CCIR) ? in tda1997x_configure_vidout()
838 reg |= pdata->vidout_delay_pclk << PCLK_DELAY_SHIFT; in tda1997x_configure_vidout()
839 reg |= pdata->vidout_inv_pclk << PCLK_INV_SHIFT; in tda1997x_configure_vidout()
840 io_write(sd, REG_PCLK, reg); in tda1997x_configure_vidout()
842 /* Configure pre-filter */ in tda1997x_configure_vidout()
845 if ((state->vid_fmt == OF_FMT_422_SMPT) || in tda1997x_configure_vidout()
846 (state->vid_fmt == OF_FMT_422_CCIR)) { in tda1997x_configure_vidout()
851 io_write(sd, REG_FILTERS_CTRL, prefilter); in tda1997x_configure_vidout()
854 reg = state->vid_fmt & OF_FMT_MASK; in tda1997x_configure_vidout()
855 if (state->vid_fmt == OF_FMT_422_CCIR) in tda1997x_configure_vidout()
858 io_write(sd, REG_OF, reg); in tda1997x_configure_vidout()
861 reg = io_read(sd, REG_VDP_CTRL); in tda1997x_configure_vidout()
862 /* pre-filter is needed unless (REG_FILTERS_CTRL == 0) */ in tda1997x_configure_vidout()
868 if (state->vid_fmt == OF_FMT_444) in tda1997x_configure_vidout()
874 if ((pdata->vidout_delay_vs < 4) || (pdata->vidout_delay_hs < 4)) in tda1997x_configure_vidout()
876 io_write(sd, REG_VDP_CTRL, reg); in tda1997x_configure_vidout()
879 reg = pdata->vidout_delay_de << DE_FREF_DELAY_SHIFT | in tda1997x_configure_vidout()
880 pdata->vidout_inv_de << DE_FREF_INV_SHIFT | in tda1997x_configure_vidout()
881 pdata->vidout_sel_de << DE_FREF_SEL_SHIFT; in tda1997x_configure_vidout()
882 io_write(sd, REG_DE_FREF, reg); in tda1997x_configure_vidout()
885 if (state->vid_fmt != OF_FMT_422_CCIR) { in tda1997x_configure_vidout()
886 reg = pdata->vidout_delay_hs << HS_HREF_DELAY_SHIFT | in tda1997x_configure_vidout()
887 pdata->vidout_inv_hs << HS_HREF_INV_SHIFT | in tda1997x_configure_vidout()
888 pdata->vidout_sel_hs << HS_HREF_SEL_SHIFT; in tda1997x_configure_vidout()
891 io_write(sd, REG_HS_HREF, reg); in tda1997x_configure_vidout()
894 if (state->vid_fmt != OF_FMT_422_CCIR) { in tda1997x_configure_vidout()
895 reg = pdata->vidout_delay_vs << VS_VREF_DELAY_SHIFT | in tda1997x_configure_vidout()
896 pdata->vidout_inv_vs << VS_VREF_INV_SHIFT | in tda1997x_configure_vidout()
897 pdata->vidout_sel_vs << VS_VREF_SEL_SHIFT; in tda1997x_configure_vidout()
900 io_write(sd, REG_VS_VREF, reg); in tda1997x_configure_vidout()
907 tda1997x_configure_audout(struct v4l2_subdev *sd, u8 channel_assignment) in tda1997x_configure_audout() argument
909 struct tda1997x_state *state = to_state(sd); in tda1997x_configure_audout()
910 struct tda1997x_platform_data *pdata = &state->pdata; in tda1997x_configure_audout()
914 if (!pdata->audout_format) in tda1997x_configure_audout()
917 /* channel assignment (CEA-861-D Table 20) */ in tda1997x_configure_audout()
918 io_write(sd, REG_AUDIO_PATH, channel_assignment); in tda1997x_configure_audout()
922 switch (pdata->audout_format) { in tda1997x_configure_audout()
930 switch (state->audio_type) { in tda1997x_configure_audout()
943 if (pdata->audout_layout == 1) { in tda1997x_configure_audout()
946 if (pdata->audout_format == AUDFMT_TYPE_SPDIF) in tda1997x_configure_audout()
954 if (pdata->audout_width == 32) in tda1997x_configure_audout()
960 if (pdata->audio_auto_mute) in tda1997x_configure_audout()
963 if (pdata->audout_invert_clk) in tda1997x_configure_audout()
965 io_write(sd, REG_AUDCFG, reg); in tda1997x_configure_audout()
968 reg = (pdata->audout_layout) ? AUDIO_LAYOUT_LAYOUT1 : 0; in tda1997x_configure_audout()
969 if (!pdata->audout_layoutauto) in tda1997x_configure_audout()
973 io_write(sd, REG_AUDIO_LAYOUT, reg); in tda1997x_configure_audout()
976 io_write(sd, REG_FIFO_LATENCY_VAL, 0x80); in tda1997x_configure_audout()
1006 if (pdata->audout_format == AUDFMT_TYPE_I2S) in tda1997x_configure_audout()
1008 io_write(sd, REG_AUDIO_OUT_ENABLE, reg); in tda1997x_configure_audout()
1011 io_write(sd, REG_TEST_MODE, 0x00); in tda1997x_configure_audout()
1018 tda1997x_hdmi_info_reset(struct v4l2_subdev *sd, u8 info_rst, bool reset_sus) in tda1997x_hdmi_info_reset() argument
1023 reg = io_read(sd, REG_HDMI_INFO_RST); in tda1997x_hdmi_info_reset()
1024 io_write(sd, REG_HDMI_INFO_RST, info_rst); in tda1997x_hdmi_info_reset()
1028 reg = io_read(sd, REG_INT_FLG_CLR_MODE); in tda1997x_hdmi_info_reset()
1029 io_write(sd, REG_INT_FLG_CLR_MODE, reg); in tda1997x_hdmi_info_reset()
1032 /* Disable REFTIM to restart start-up-sequencer (SUS) */ in tda1997x_hdmi_info_reset()
1033 reg = io_read(sd, REG_RATE_CTRL); in tda1997x_hdmi_info_reset()
1037 reg = io_write(sd, REG_RATE_CTRL, reg); in tda1997x_hdmi_info_reset()
1045 struct v4l2_subdev *sd = &state->sd; in tda1997x_power_mode() local
1050 io_write(sd, REG_PON_OVR_EN, PON_DIS); in tda1997x_power_mode()
1052 io_write(sd, REG_CFG1, PON_EN); in tda1997x_power_mode()
1054 io_write(sd, REG_DEEP_PLL7_BYP, PON_DIS); in tda1997x_power_mode()
1056 reg = io_read(sd, REG_OF); in tda1997x_power_mode()
1058 io_write(sd, REG_OF, reg); in tda1997x_power_mode()
1062 reg = io_read(sd, REG_OF); in tda1997x_power_mode()
1064 io_write(sd, REG_OF, reg); in tda1997x_power_mode()
1066 io_write(sd, REG_DEEP_PLL7_BYP, PON_EN); in tda1997x_power_mode()
1068 io_write(sd, REG_CFG1, PON_DIS); in tda1997x_power_mode()
1070 io_write(sd, REG_PON_OVR_EN, PON_EN); in tda1997x_power_mode()
1075 tda1997x_detect_tx_5v(struct v4l2_subdev *sd) in tda1997x_detect_tx_5v() argument
1077 u8 reg = io_read(sd, REG_DETECT_5V); in tda1997x_detect_tx_5v()
1083 tda1997x_detect_tx_hpd(struct v4l2_subdev *sd) in tda1997x_detect_tx_hpd() argument
1085 u8 reg = io_read(sd, REG_DETECT_5V); in tda1997x_detect_tx_hpd()
1094 struct v4l2_subdev *sd = &state->sd; in tda1997x_detect_std() local
1106 vper = io_read24(sd, REG_V_PER) & MASK_VPER; in tda1997x_detect_std()
1107 hper = io_read16(sd, REG_H_PER) & MASK_HPER; in tda1997x_detect_std()
1108 hsper = io_read16(sd, REG_HS_WIDTH) & MASK_HSWIDTH; in tda1997x_detect_std()
1109 v4l2_dbg(1, debug, sd, "Signal Timings: %u/%u/%u\n", vper, hper, hsper); in tda1997x_detect_std()
1111 return -ENOLINK; in tda1997x_detect_std()
1115 u32 lines, width, _hper, _hsper; in tda1997x_detect_std() local
1121 lines = V4L2_DV_BT_FRAME_HEIGHT(bt); in tda1997x_detect_std()
1122 _hper = (u32)bt->pixelclock / width; in tda1997x_detect_std()
1123 if (bt->interlaced) in tda1997x_detect_std()
1124 lines /= 2; in tda1997x_detect_std()
1125 /* vper +/- 0.7% */ in tda1997x_detect_std()
1126 vmin = ((27000000 / 1000) * 993) / _hper * lines; in tda1997x_detect_std()
1127 vmax = ((27000000 / 1000) * 1007) / _hper * lines; in tda1997x_detect_std()
1128 /* hper +/- 1.0% */ in tda1997x_detect_std()
1131 /* hsper +/- 2 (take care to avoid 32bit overflow) */ in tda1997x_detect_std()
1132 _hsper = 27000 * bt->hsync / ((u32)bt->pixelclock/1000); in tda1997x_detect_std()
1133 hsmin = _hsper - 2; in tda1997x_detect_std()
1143 v4l2_print_dv_timings(sd->name, "Detected format: ", in tda1997x_detect_std()
1152 v4l_err(state->client, "no resolution match for timings: %d/%d/%d\n", in tda1997x_detect_std()
1154 return -ERANGE; in tda1997x_detect_std()
1160 struct v4l2_subdev *sd = &state->sd; in tda1997x_reset_n1() local
1164 io_write(sd, REG_CLK_CFG, CLK_CFG_SEL_ACLK_EN | CLK_CFG_SEL_ACLK); in tda1997x_reset_n1()
1165 io_write(sd, REG_PON_OVR_EN, PON_EN); in tda1997x_reset_n1()
1166 io_write(sd, REG_PON_CBIAS, PON_EN); in tda1997x_reset_n1()
1167 io_write(sd, REG_PON_PLL, PON_EN); in tda1997x_reset_n1()
1169 reg = io_read(sd, REG_MODE_REC_CFG1); in tda1997x_reset_n1()
1172 io_write(sd, REG_MODE_REC_CFG1, reg); in tda1997x_reset_n1()
1173 io_write(sd, REG_CLK_CFG, CLK_CFG_DIS); in tda1997x_reset_n1()
1174 io_write(sd, REG_PON_OVR_EN, PON_DIS); in tda1997x_reset_n1()
1175 reg = io_read(sd, REG_MODE_REC_CFG1); in tda1997x_reset_n1()
1177 io_write(sd, REG_MODE_REC_CFG1, reg); in tda1997x_reset_n1()
1187 tda1997x_read_activity_status_regs(struct v4l2_subdev *sd) in tda1997x_read_activity_status_regs() argument
1192 reg = io_read(sd, REG_CLK_A_STATUS); in tda1997x_read_activity_status_regs()
1199 reg = io_read(sd, REG_CLK_B_STATUS); in tda1997x_read_activity_status_regs()
1206 reg = io_read(sd, REG_SUS_STATUS); in tda1997x_read_activity_status_regs()
1220 struct v4l2_hdmi_colorimetry *c = &state->colorimetry; in set_rgb_quantization_range()
1222 state->colorimetry = v4l2_hdmi_rx_colorimetry(&state->avi_infoframe, in set_rgb_quantization_range()
1224 state->timings.bt.height); in set_rgb_quantization_range()
1226 if (c->ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) { in set_rgb_quantization_range()
1227 switch (state->rgb_quantization_range) { in set_rgb_quantization_range()
1229 c->quantization = V4L2_QUANTIZATION_FULL_RANGE; in set_rgb_quantization_range()
1232 c->quantization = V4L2_QUANTIZATION_LIM_RANGE; in set_rgb_quantization_range()
1236 v4l_dbg(1, debug, state->client, in set_rgb_quantization_range()
1238 state->avi_infoframe.colorspace, c->colorspace, in set_rgb_quantization_range()
1239 state->avi_infoframe.colorimetry, in set_rgb_quantization_range()
1240 v4l2_quantization_names[c->quantization], in set_rgb_quantization_range()
1241 state->avi_infoframe.content_type); in set_rgb_quantization_range()
1248 struct v4l2_subdev *sd = &state->sd; in tda1997x_parse_infoframe() local
1255 len = io_readn(sd, addr, sizeof(buffer), buffer); in tda1997x_parse_infoframe()
1258 v4l_err(state->client, in tda1997x_parse_infoframe()
1263 hdmi_infoframe_log(KERN_INFO, &state->client->dev, &frame); in tda1997x_parse_infoframe()
1270 state->audio_samplerate = 32000; in tda1997x_parse_infoframe()
1273 state->audio_samplerate = 44100; in tda1997x_parse_infoframe()
1276 state->audio_samplerate = 48000; in tda1997x_parse_infoframe()
1279 state->audio_samplerate = 88200; in tda1997x_parse_infoframe()
1282 state->audio_samplerate = 96000; in tda1997x_parse_infoframe()
1285 state->audio_samplerate = 176400; in tda1997x_parse_infoframe()
1288 state->audio_samplerate = 192000; in tda1997x_parse_infoframe()
1298 state->audio_samplesize = 16; in tda1997x_parse_infoframe()
1301 state->audio_samplesize = 20; in tda1997x_parse_infoframe()
1304 state->audio_samplesize = 24; in tda1997x_parse_infoframe()
1312 state->audio_channels = frame.audio.channels; in tda1997x_parse_infoframe()
1314 frame.audio.channel_allocation != state->audio_ch_alloc) { in tda1997x_parse_infoframe()
1316 state->audio_ch_alloc = frame.audio.channel_allocation; in tda1997x_parse_infoframe()
1317 tda1997x_configure_audout(sd, state->audio_ch_alloc); in tda1997x_parse_infoframe()
1319 tda1997x_hdmi_info_reset(sd, RESET_AUDIO, false); in tda1997x_parse_infoframe()
1325 state->avi_infoframe = frame.avi; in tda1997x_parse_infoframe()
1329 reg = io_read(sd, REG_PIX_REPEAT); in tda1997x_parse_infoframe()
1333 io_write(sd, REG_PIX_REPEAT, reg); in tda1997x_parse_infoframe()
1335 /* ConfigurePixelRepeater: repeat n-times each pixel */ in tda1997x_parse_infoframe()
1336 reg = io_read(sd, REG_PIX_REPEAT); in tda1997x_parse_infoframe()
1339 io_write(sd, REG_PIX_REPEAT, reg); in tda1997x_parse_infoframe()
1342 tda1997x_configure_csc(sd); in tda1997x_parse_infoframe()
1352 struct v4l2_subdev *sd = &state->sd; in tda1997x_irq_sus() local
1355 source = io_read(sd, REG_INT_FLG_CLR_SUS); in tda1997x_irq_sus()
1356 io_write(sd, REG_INT_FLG_CLR_SUS, source); in tda1997x_irq_sus()
1360 if (state->mptrw_in_progress) in tda1997x_irq_sus()
1361 state->mptrw_in_progress = 0; in tda1997x_irq_sus()
1366 reg = io_read(sd, REG_HDMI_INFO_RST); in tda1997x_irq_sus()
1368 io_write(sd, REG_HDMI_INFO_RST, reg); in tda1997x_irq_sus()
1370 io_write(sd, REG_HDMI_INFO_RST, reg); in tda1997x_irq_sus()
1373 state->hdmi_status = 0; in tda1997x_irq_sus()
1377 reg = io_read(sd, REG_SUS_STATUS); in tda1997x_irq_sus()
1384 reg = io_read(sd, REG_SUS_STATUS); in tda1997x_irq_sus()
1386 v4l_err(state->client, "BAD SUS STATUS\n"); in tda1997x_irq_sus()
1392 v4l2_subdev_notify_event(&state->sd, &tda1997x_ev_fmt); in tda1997x_irq_sus()
1398 struct v4l2_subdev *sd = &state->sd; in tda1997x_irq_ddc() local
1401 source = io_read(sd, REG_INT_FLG_CLR_DDC); in tda1997x_irq_ddc()
1402 io_write(sd, REG_INT_FLG_CLR_DDC, source); in tda1997x_irq_ddc()
1405 if (state->mptrw_in_progress) in tda1997x_irq_ddc()
1406 state->mptrw_in_progress = 0; in tda1997x_irq_ddc()
1411 v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, in tda1997x_irq_ddc()
1412 tda1997x_detect_tx_5v(sd)); in tda1997x_irq_ddc()
1418 struct v4l2_subdev *sd = &state->sd; in tda1997x_irq_rate() local
1423 source = io_read(sd, REG_INT_FLG_CLR_RATE); in tda1997x_irq_rate()
1424 io_write(sd, REG_INT_FLG_CLR_RATE, source); in tda1997x_irq_rate()
1427 irq_status = tda1997x_read_activity_status_regs(sd); in tda1997x_irq_rate()
1435 irq_status = tda1997x_read_activity_status_regs(sd); in tda1997x_irq_rate()
1436 reg = io_read(sd, REG_INT_FLG_CLR_RATE); in tda1997x_irq_rate()
1437 io_write(sd, REG_INT_FLG_CLR_RATE, reg); in tda1997x_irq_rate()
1447 if ((irq_status & mask) != (state->activity_status & mask)) { in tda1997x_irq_rate()
1450 v4l_info(state->client, in tda1997x_irq_rate()
1451 "HDMI-%c: Digital Activity Lost\n", in tda1997x_irq_rate()
1455 reg = io_read(sd, REG_PIX_REPEAT); in tda1997x_irq_rate()
1458 io_write(sd, REG_PIX_REPEAT, reg); in tda1997x_irq_rate()
1460 if (state->chip_revision == 0) in tda1997x_irq_rate()
1463 state->input_detect[input] = 0; in tda1997x_irq_rate()
1464 v4l2_subdev_notify_event(sd, &tda1997x_ev_fmt); in tda1997x_irq_rate()
1469 v4l_info(state->client, in tda1997x_irq_rate()
1470 "HDMI-%c: Digital Activity Detected\n", in tda1997x_irq_rate()
1472 state->input_detect[input] = 1; in tda1997x_irq_rate()
1476 state->activity_status = (irq_status & mask); in tda1997x_irq_rate()
1483 struct v4l2_subdev *sd = &state->sd; in tda1997x_irq_info() local
1486 source = io_read(sd, REG_INT_FLG_CLR_INFO); in tda1997x_irq_info()
1487 io_write(sd, REG_INT_FLG_CLR_INFO, source); in tda1997x_irq_info()
1510 struct v4l2_subdev *sd = &state->sd; in tda1997x_irq_audio() local
1513 source = io_read(sd, REG_INT_FLG_CLR_AUDIO); in tda1997x_irq_audio()
1514 io_write(sd, REG_INT_FLG_CLR_AUDIO, source); in tda1997x_irq_audio()
1520 reg = io_read(sd, REG_SUS_STATUS); in tda1997x_irq_audio()
1522 reg = io_read(sd, REG_HDMI_INFO_RST); in tda1997x_irq_audio()
1524 io_write(sd, REG_HDMI_INFO_RST, reg); in tda1997x_irq_audio()
1526 io_write(sd, REG_HDMI_INFO_RST, reg); in tda1997x_irq_audio()
1536 reg = io_read(sd, REG_AUDIO_FREQ); in tda1997x_irq_audio()
1537 state->audio_samplerate = freq[reg & 7]; in tda1997x_irq_audio()
1538 v4l_info(state->client, "Audio Frequency Change: %dHz\n", in tda1997x_irq_audio()
1539 state->audio_samplerate); in tda1997x_irq_audio()
1542 reg = io_read(sd, REG_AUDIO_FLAGS); in tda1997x_irq_audio()
1544 state->audio_type = AUDCFG_TYPE_DST; in tda1997x_irq_audio()
1546 state->audio_type = AUDCFG_TYPE_OBA; in tda1997x_irq_audio()
1548 state->audio_type = AUDCFG_TYPE_HBR; in tda1997x_irq_audio()
1550 state->audio_type = AUDCFG_TYPE_PCM; in tda1997x_irq_audio()
1551 v4l_info(state->client, "Audio Type: %s\n", in tda1997x_irq_audio()
1552 audtype_names[state->audio_type]); in tda1997x_irq_audio()
1558 struct v4l2_subdev *sd = &state->sd; in tda1997x_irq_hdcp() local
1561 source = io_read(sd, REG_INT_FLG_CLR_HDCP); in tda1997x_irq_hdcp()
1562 io_write(sd, REG_INT_FLG_CLR_HDCP, source); in tda1997x_irq_hdcp()
1566 state->mptrw_in_progress = 0; in tda1997x_irq_hdcp()
1569 reg = io_read(sd, REG_INT_MASK_TOP); in tda1997x_irq_hdcp()
1571 io_write(sd, REG_INT_MASK_TOP, reg); in tda1997x_irq_hdcp()
1579 struct v4l2_subdev *sd = &state->sd; in tda1997x_isr_thread() local
1582 mutex_lock(&state->lock); in tda1997x_isr_thread()
1585 flags = io_read(sd, REG_INT_FLG_CLR_TOP); in tda1997x_isr_thread()
1610 mutex_unlock(&state->lock); in tda1997x_isr_thread()
1615 /* -----------------------------------------------------------------------------
1620 tda1997x_g_input_status(struct v4l2_subdev *sd, u32 *status) in tda1997x_g_input_status() argument
1622 struct tda1997x_state *state = to_state(sd); in tda1997x_g_input_status()
1627 mutex_lock(&state->lock); in tda1997x_g_input_status()
1628 vper = io_read24(sd, REG_V_PER) & MASK_VPER; in tda1997x_g_input_status()
1629 hper = io_read16(sd, REG_H_PER) & MASK_HPER; in tda1997x_g_input_status()
1630 hsper = io_read16(sd, REG_HS_WIDTH) & MASK_HSWIDTH; in tda1997x_g_input_status()
1642 v4l2_dbg(1, debug, sd, "inputs:%d/%d timings:%d/%d/%d\n", in tda1997x_g_input_status()
1643 state->input_detect[0], state->input_detect[1], in tda1997x_g_input_status()
1645 if (!state->input_detect[0] && !state->input_detect[1]) in tda1997x_g_input_status()
1651 mutex_unlock(&state->lock); in tda1997x_g_input_status()
1656 static int tda1997x_s_dv_timings(struct v4l2_subdev *sd, in tda1997x_s_dv_timings() argument
1659 struct tda1997x_state *state = to_state(sd); in tda1997x_s_dv_timings()
1661 v4l_dbg(1, debug, state->client, "%s\n", __func__); in tda1997x_s_dv_timings()
1663 if (v4l2_match_dv_timings(&state->timings, timings, 0, false)) in tda1997x_s_dv_timings()
1668 return -ERANGE; in tda1997x_s_dv_timings()
1670 mutex_lock(&state->lock); in tda1997x_s_dv_timings()
1671 state->timings = *timings; in tda1997x_s_dv_timings()
1673 tda1997x_configure_vhref(sd); in tda1997x_s_dv_timings()
1675 tda1997x_configure_csc(sd); in tda1997x_s_dv_timings()
1676 mutex_unlock(&state->lock); in tda1997x_s_dv_timings()
1681 static int tda1997x_g_dv_timings(struct v4l2_subdev *sd, in tda1997x_g_dv_timings() argument
1684 struct tda1997x_state *state = to_state(sd); in tda1997x_g_dv_timings()
1686 v4l_dbg(1, debug, state->client, "%s\n", __func__); in tda1997x_g_dv_timings()
1687 mutex_lock(&state->lock); in tda1997x_g_dv_timings()
1688 *timings = state->timings; in tda1997x_g_dv_timings()
1689 mutex_unlock(&state->lock); in tda1997x_g_dv_timings()
1694 static int tda1997x_query_dv_timings(struct v4l2_subdev *sd, in tda1997x_query_dv_timings() argument
1697 struct tda1997x_state *state = to_state(sd); in tda1997x_query_dv_timings()
1699 v4l_dbg(1, debug, state->client, "%s\n", __func__); in tda1997x_query_dv_timings()
1701 mutex_lock(&state->lock); in tda1997x_query_dv_timings()
1703 mutex_unlock(&state->lock); in tda1997x_query_dv_timings()
1716 /* -----------------------------------------------------------------------------
1720 static int tda1997x_init_cfg(struct v4l2_subdev *sd, in tda1997x_init_cfg() argument
1723 struct tda1997x_state *state = to_state(sd); in tda1997x_init_cfg()
1726 mf = v4l2_subdev_get_try_format(sd, cfg, 0); in tda1997x_init_cfg()
1727 mf->code = state->mbus_codes[0]; in tda1997x_init_cfg()
1732 static int tda1997x_enum_mbus_code(struct v4l2_subdev *sd, in tda1997x_enum_mbus_code() argument
1736 struct tda1997x_state *state = to_state(sd); in tda1997x_enum_mbus_code()
1738 v4l_dbg(1, debug, state->client, "%s %d\n", __func__, code->index); in tda1997x_enum_mbus_code()
1739 if (code->index >= ARRAY_SIZE(state->mbus_codes)) in tda1997x_enum_mbus_code()
1740 return -EINVAL; in tda1997x_enum_mbus_code()
1742 if (!state->mbus_codes[code->index]) in tda1997x_enum_mbus_code()
1743 return -EINVAL; in tda1997x_enum_mbus_code()
1745 code->code = state->mbus_codes[code->index]; in tda1997x_enum_mbus_code()
1756 bt = &state->timings.bt; in tda1997x_fill_format()
1757 format->width = bt->width; in tda1997x_fill_format()
1758 format->height = bt->height; in tda1997x_fill_format()
1759 format->colorspace = state->colorimetry.colorspace; in tda1997x_fill_format()
1760 format->field = (bt->interlaced) ? in tda1997x_fill_format()
1764 static int tda1997x_get_format(struct v4l2_subdev *sd, in tda1997x_get_format() argument
1768 struct tda1997x_state *state = to_state(sd); in tda1997x_get_format()
1770 v4l_dbg(1, debug, state->client, "%s pad=%d which=%d\n", in tda1997x_get_format()
1771 __func__, format->pad, format->which); in tda1997x_get_format()
1773 tda1997x_fill_format(state, &format->format); in tda1997x_get_format()
1775 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in tda1997x_get_format()
1778 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); in tda1997x_get_format()
1779 format->format.code = fmt->code; in tda1997x_get_format()
1781 format->format.code = state->mbus_code; in tda1997x_get_format()
1786 static int tda1997x_set_format(struct v4l2_subdev *sd, in tda1997x_set_format() argument
1790 struct tda1997x_state *state = to_state(sd); in tda1997x_set_format()
1794 v4l_dbg(1, debug, state->client, "%s pad=%d which=%d fmt=0x%x\n", in tda1997x_set_format()
1795 __func__, format->pad, format->which, format->format.code); in tda1997x_set_format()
1797 for (i = 0; i < ARRAY_SIZE(state->mbus_codes); i++) { in tda1997x_set_format()
1798 if (format->format.code == state->mbus_codes[i]) { in tda1997x_set_format()
1799 code = state->mbus_codes[i]; in tda1997x_set_format()
1804 code = state->mbus_codes[0]; in tda1997x_set_format()
1806 tda1997x_fill_format(state, &format->format); in tda1997x_set_format()
1807 format->format.code = code; in tda1997x_set_format()
1809 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in tda1997x_set_format()
1812 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); in tda1997x_set_format()
1813 *fmt = format->format; in tda1997x_set_format()
1815 int ret = tda1997x_setup_format(state, format->format.code); in tda1997x_set_format()
1819 /* mbus_code has changed - re-configure csc/vidout */ in tda1997x_set_format()
1820 tda1997x_configure_csc(sd); in tda1997x_set_format()
1827 static int tda1997x_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in tda1997x_get_edid() argument
1829 struct tda1997x_state *state = to_state(sd); in tda1997x_get_edid()
1831 v4l_dbg(1, debug, state->client, "%s pad=%d\n", __func__, edid->pad); in tda1997x_get_edid()
1832 memset(edid->reserved, 0, sizeof(edid->reserved)); in tda1997x_get_edid()
1834 if (edid->start_block == 0 && edid->blocks == 0) { in tda1997x_get_edid()
1835 edid->blocks = state->edid.blocks; in tda1997x_get_edid()
1839 if (!state->edid.present) in tda1997x_get_edid()
1840 return -ENODATA; in tda1997x_get_edid()
1842 if (edid->start_block >= state->edid.blocks) in tda1997x_get_edid()
1843 return -EINVAL; in tda1997x_get_edid()
1845 if (edid->start_block + edid->blocks > state->edid.blocks) in tda1997x_get_edid()
1846 edid->blocks = state->edid.blocks - edid->start_block; in tda1997x_get_edid()
1848 memcpy(edid->edid, state->edid.edid + edid->start_block * 128, in tda1997x_get_edid()
1849 edid->blocks * 128); in tda1997x_get_edid()
1854 static int tda1997x_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in tda1997x_set_edid() argument
1856 struct tda1997x_state *state = to_state(sd); in tda1997x_set_edid()
1859 v4l_dbg(1, debug, state->client, "%s pad=%d\n", __func__, edid->pad); in tda1997x_set_edid()
1860 memset(edid->reserved, 0, sizeof(edid->reserved)); in tda1997x_set_edid()
1862 if (edid->start_block != 0) in tda1997x_set_edid()
1863 return -EINVAL; in tda1997x_set_edid()
1865 if (edid->blocks == 0) { in tda1997x_set_edid()
1866 state->edid.blocks = 0; in tda1997x_set_edid()
1867 state->edid.present = 0; in tda1997x_set_edid()
1868 tda1997x_disable_edid(sd); in tda1997x_set_edid()
1872 if (edid->blocks > 2) { in tda1997x_set_edid()
1873 edid->blocks = 2; in tda1997x_set_edid()
1874 return -E2BIG; in tda1997x_set_edid()
1877 tda1997x_disable_edid(sd); in tda1997x_set_edid()
1881 io_write(sd, REG_EDID_IN_BYTE0 + i, edid->edid[i]); in tda1997x_set_edid()
1885 io_write(sd, REG_EDID_IN_BYTE128 + i, edid->edid[i+128]); in tda1997x_set_edid()
1888 memcpy(state->edid.edid, edid->edid, 256); in tda1997x_set_edid()
1889 state->edid.blocks = edid->blocks; in tda1997x_set_edid()
1891 tda1997x_enable_edid(sd); in tda1997x_set_edid()
1896 static int tda1997x_get_dv_timings_cap(struct v4l2_subdev *sd, in tda1997x_get_dv_timings_cap() argument
1903 static int tda1997x_enum_dv_timings(struct v4l2_subdev *sd, in tda1997x_enum_dv_timings() argument
1921 /* -----------------------------------------------------------------------------
1925 static int tda1997x_log_infoframe(struct v4l2_subdev *sd, int addr) in tda1997x_log_infoframe() argument
1927 struct tda1997x_state *state = to_state(sd); in tda1997x_log_infoframe()
1933 len = io_readn(sd, addr, sizeof(buffer), buffer); in tda1997x_log_infoframe()
1934 v4l2_dbg(1, debug, sd, "infoframe: addr=%d len=%d\n", addr, len); in tda1997x_log_infoframe()
1937 v4l_err(state->client, in tda1997x_log_infoframe()
1942 hdmi_infoframe_log(KERN_INFO, &state->client->dev, &frame); in tda1997x_log_infoframe()
1947 static int tda1997x_log_status(struct v4l2_subdev *sd) in tda1997x_log_status() argument
1949 struct tda1997x_state *state = to_state(sd); in tda1997x_log_status()
1951 struct hdmi_avi_infoframe *avi = &state->avi_infoframe; in tda1997x_log_status()
1953 v4l2_info(sd, "-----Chip status-----\n"); in tda1997x_log_status()
1954 v4l2_info(sd, "Chip: %s N%d\n", state->info->name, in tda1997x_log_status()
1955 state->chip_revision + 1); in tda1997x_log_status()
1956 v4l2_info(sd, "EDID Enabled: %s\n", state->edid.present ? "yes" : "no"); in tda1997x_log_status()
1958 v4l2_info(sd, "-----Signal status-----\n"); in tda1997x_log_status()
1959 v4l2_info(sd, "Cable detected (+5V power): %s\n", in tda1997x_log_status()
1960 tda1997x_detect_tx_5v(sd) ? "yes" : "no"); in tda1997x_log_status()
1961 v4l2_info(sd, "HPD detected: %s\n", in tda1997x_log_status()
1962 tda1997x_detect_tx_hpd(sd) ? "yes" : "no"); in tda1997x_log_status()
1964 v4l2_info(sd, "-----Video Timings-----\n"); in tda1997x_log_status()
1966 case -ENOLINK: in tda1997x_log_status()
1967 v4l2_info(sd, "No video detected\n"); in tda1997x_log_status()
1969 case -ERANGE: in tda1997x_log_status()
1970 v4l2_info(sd, "Invalid signal detected\n"); in tda1997x_log_status()
1973 v4l2_print_dv_timings(sd->name, "Configured format: ", in tda1997x_log_status()
1974 &state->timings, true); in tda1997x_log_status()
1976 v4l2_info(sd, "-----Color space-----\n"); in tda1997x_log_status()
1977 v4l2_info(sd, "Input color space: %s %s %s", in tda1997x_log_status()
1978 hdmi_colorspace_names[avi->colorspace], in tda1997x_log_status()
1979 (avi->colorspace == HDMI_COLORSPACE_RGB) ? "" : in tda1997x_log_status()
1980 hdmi_colorimetry_names[avi->colorimetry], in tda1997x_log_status()
1981 v4l2_quantization_names[state->colorimetry.quantization]); in tda1997x_log_status()
1982 v4l2_info(sd, "Output color space: %s", in tda1997x_log_status()
1983 vidfmt_names[state->vid_fmt]); in tda1997x_log_status()
1984 v4l2_info(sd, "Color space conversion: %s", state->conv ? in tda1997x_log_status()
1985 state->conv->name : "None"); in tda1997x_log_status()
1987 v4l2_info(sd, "-----Audio-----\n"); in tda1997x_log_status()
1988 if (state->audio_channels) { in tda1997x_log_status()
1989 v4l2_info(sd, "audio: %dch %dHz\n", state->audio_channels, in tda1997x_log_status()
1990 state->audio_samplerate); in tda1997x_log_status()
1992 v4l2_info(sd, "audio: none\n"); in tda1997x_log_status()
1995 v4l2_info(sd, "-----Infoframes-----\n"); in tda1997x_log_status()
1996 tda1997x_log_infoframe(sd, AUD_IF); in tda1997x_log_status()
1997 tda1997x_log_infoframe(sd, SPD_IF); in tda1997x_log_status()
1998 tda1997x_log_infoframe(sd, AVI_IF); in tda1997x_log_status()
2003 static int tda1997x_subscribe_event(struct v4l2_subdev *sd, in tda1997x_subscribe_event() argument
2007 switch (sub->type) { in tda1997x_subscribe_event()
2009 return v4l2_src_change_event_subdev_subscribe(sd, fh, sub); in tda1997x_subscribe_event()
2011 return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub); in tda1997x_subscribe_event()
2013 return -EINVAL; in tda1997x_subscribe_event()
2023 /* -----------------------------------------------------------------------------
2033 /* -----------------------------------------------------------------------------
2039 struct v4l2_subdev *sd = to_sd(ctrl); in tda1997x_s_ctrl() local
2040 struct tda1997x_state *state = to_state(sd); in tda1997x_s_ctrl()
2042 switch (ctrl->id) { in tda1997x_s_ctrl()
2045 state->rgb_quantization_range = ctrl->val; in tda1997x_s_ctrl()
2047 tda1997x_configure_csc(sd); in tda1997x_s_ctrl()
2051 return -EINVAL; in tda1997x_s_ctrl()
2056 struct v4l2_subdev *sd = to_sd(ctrl); in tda1997x_g_volatile_ctrl() local
2057 struct tda1997x_state *state = to_state(sd); in tda1997x_g_volatile_ctrl()
2059 if (ctrl->id == V4L2_CID_DV_RX_IT_CONTENT_TYPE) { in tda1997x_g_volatile_ctrl()
2060 ctrl->val = state->avi_infoframe.content_type; in tda1997x_g_volatile_ctrl()
2063 return -EINVAL; in tda1997x_g_volatile_ctrl()
2071 static int tda1997x_core_init(struct v4l2_subdev *sd) in tda1997x_core_init() argument
2073 struct tda1997x_state *state = to_state(sd); in tda1997x_core_init()
2074 struct tda1997x_platform_data *pdata = &state->pdata; in tda1997x_core_init()
2079 io_write(sd, REG_HPD_AUTO_CTRL, HPD_AUTO_HPD_UNSEL); in tda1997x_core_init()
2080 if (state->chip_revision == 0) { in tda1997x_core_init()
2081 io_write(sd, REG_MAN_SUS_HDMI_SEL, MAN_DIS_HDCP | MAN_RST_HDCP); in tda1997x_core_init()
2082 io_write(sd, REG_CGU_DBG_SEL, 1 << CGU_DBG_CLK_SEL_SHIFT); in tda1997x_core_init()
2085 /* reset infoframe at end of start-up-sequencer */ in tda1997x_core_init()
2086 io_write(sd, REG_SUS_SET_RGB2, 0x06); in tda1997x_core_init()
2087 io_write(sd, REG_SUS_SET_RGB3, 0x06); in tda1997x_core_init()
2089 /* Enable TMDS pull-ups */ in tda1997x_core_init()
2090 io_write(sd, REG_RT_MAN_CTRL, RT_MAN_CTRL_RT | in tda1997x_core_init()
2094 tda1997x_cec_write(sd, REG_PWR_CONTROL & 0xff, 0x04); in tda1997x_core_init()
2096 tda1997x_cec_write(sd, REG_OSC_DIVIDER & 0xff, 0x03); in tda1997x_core_init()
2097 tda1997x_cec_write(sd, REG_EN_OSC_PERIOD_LSB & 0xff, 0xa0); in tda1997x_core_init()
2098 io_write(sd, REG_TIMER_D, 0x54); in tda1997x_core_init()
2100 reg = tda1997x_cec_read(sd, REG_CONTROL & 0xff); in tda1997x_core_init()
2102 tda1997x_cec_write(sd, REG_CONTROL & 0xff, reg); in tda1997x_core_init()
2106 reg = io_read(sd, REG_VERSION); in tda1997x_core_init()
2108 reg = io_read(sd, REG_CMTP_REG10); in tda1997x_core_init()
2111 io_write(sd, REG_INT_MASK_TOP, in tda1997x_core_init()
2115 io_write(sd, REG_INT_MASK_SUS, MASK_MPT | MASK_FMT | MASK_SUS_END); in tda1997x_core_init()
2117 io_write(sd, REG_INT_MASK_RATE, MASK_RATE_B_ST | MASK_RATE_A_ST); in tda1997x_core_init()
2119 io_write(sd, REG_INT_MASK_INFO, in tda1997x_core_init()
2122 io_write(sd, REG_INT_MASK_AUDIO, in tda1997x_core_init()
2126 io_write(sd, REG_INT_MASK_HDCP, MASK_STATE_C5); in tda1997x_core_init()
2128 io_write(sd, REG_INT_MASK_DDC, MASK_DET_5V); in tda1997x_core_init()
2130 io_write(sd, REG_INT_MASK_AFE, 0); in tda1997x_core_init()
2131 io_write(sd, REG_INT_MASK_MODE, 0); in tda1997x_core_init()
2134 io_write(sd, REG_INT_FLG_CLR_TOP, 0xff); in tda1997x_core_init()
2135 io_write(sd, REG_INT_FLG_CLR_SUS, 0xff); in tda1997x_core_init()
2136 io_write(sd, REG_INT_FLG_CLR_DDC, 0xff); in tda1997x_core_init()
2137 io_write(sd, REG_INT_FLG_CLR_RATE, 0xff); in tda1997x_core_init()
2138 io_write(sd, REG_INT_FLG_CLR_MODE, 0xff); in tda1997x_core_init()
2139 io_write(sd, REG_INT_FLG_CLR_INFO, 0xff); in tda1997x_core_init()
2140 io_write(sd, REG_INT_FLG_CLR_AUDIO, 0xff); in tda1997x_core_init()
2141 io_write(sd, REG_INT_FLG_CLR_HDCP, 0xff); in tda1997x_core_init()
2142 io_write(sd, REG_INT_FLG_CLR_AFE, 0xff); in tda1997x_core_init()
2145 if (state->chip_revision == 0) in tda1997x_core_init()
2146 io_write(sd, REG_CGU_DBG_SEL, 1 << CGU_DBG_CLK_SEL_SHIFT); in tda1997x_core_init()
2147 io_write24(sd, REG_CLK_MIN_RATE, CLK_MIN_RATE); in tda1997x_core_init()
2148 io_write24(sd, REG_CLK_MAX_RATE, CLK_MAX_RATE); in tda1997x_core_init()
2149 if (state->chip_revision == 0) in tda1997x_core_init()
2150 io_write(sd, REG_WDL_CFG, WDL_CFG_VAL); in tda1997x_core_init()
2152 io_write(sd, REG_DEEP_COLOR_CTRL, DC_FILTER_VAL); in tda1997x_core_init()
2154 io_write(sd, REG_SVC_MODE, 0x00); in tda1997x_core_init()
2156 io_write(sd, REG_INFO_CTRL, 0xff); in tda1997x_core_init()
2158 io_write(sd, REG_INFO_EXCEED, 3); in tda1997x_core_init()
2160 if (state->chip_revision == 0) in tda1997x_core_init()
2167 tda1997x_hdmi_info_reset(sd, NACK_HDCP, true); in tda1997x_core_init()
2170 tda1997x_manual_hpd(sd, HPD_LOW_BP); in tda1997x_core_init()
2173 io_write(sd, REG_HDCP_BCAPS, HDCP_HDMI | HDCP_FAST_REAUTH); in tda1997x_core_init()
2178 io_write(sd, REG_HDMI_CTRL, reg); in tda1997x_core_init()
2180 /* reset start-up-sequencer to force format detection */ in tda1997x_core_init()
2181 tda1997x_hdmi_info_reset(sd, 0, true); in tda1997x_core_init()
2184 reg = io_read(sd, REG_VDP_CTRL); in tda1997x_core_init()
2186 io_write(sd, REG_VDP_CTRL, reg); in tda1997x_core_init()
2193 v4l_dbg(1, debug, state->client, "vidout_cfg[%d]=0x%02x\n", i, in tda1997x_core_init()
2194 pdata->vidout_port_cfg[i]); in tda1997x_core_init()
2195 io_write(sd, REG_VP35_32_CTRL + i, pdata->vidout_port_cfg[i]); in tda1997x_core_init()
2199 tda1997x_configure_audout(sd, 0); in tda1997x_core_init()
2202 switch (pdata->audout_mclk_fs) { in tda1997x_core_init()
2222 io_write(sd, REG_AUDIO_CLOCK, reg); in tda1997x_core_init()
2225 tda1997x_hdmi_info_reset(sd, RESET_AI, false); in tda1997x_core_init()
2227 tda1997x_hdmi_info_reset(sd, RESET_IF, false); in tda1997x_core_init()
2229 tda1997x_hdmi_info_reset(sd, RESET_AUDIO, false); in tda1997x_core_init()
2231 tda1997x_hdmi_info_reset(sd, RESET_GAMUT, false); in tda1997x_core_init()
2234 state->hdmi_status = io_read(sd, REG_HDMI_FLAGS); in tda1997x_core_init()
2245 state->supplies); in tda1997x_set_power()
2249 state->supplies); in tda1997x_set_power()
2271 struct tda1997x_platform_data *pdata = &state->pdata; in tda1997x_parse_dt()
2282 * - HREF: active high from start to end of row in tda1997x_parse_dt()
2283 * - VS: Vertical Sync active high at beginning of frame in tda1997x_parse_dt()
2284 * - DE: Active high when data valid in tda1997x_parse_dt()
2285 * - A_CLK: 128*Fs in tda1997x_parse_dt()
2287 pdata->vidout_sel_hs = HS_HREF_SEL_HREF_VHREF; in tda1997x_parse_dt()
2288 pdata->vidout_sel_vs = VS_VREF_SEL_VREF_HDMI; in tda1997x_parse_dt()
2289 pdata->vidout_sel_de = DE_FREF_SEL_DE_VHREF; in tda1997x_parse_dt()
2291 np = state->client->dev.of_node; in tda1997x_parse_dt()
2294 return -EINVAL; in tda1997x_parse_dt()
2302 pdata->vidout_bus_type = bus_cfg.bus_type; in tda1997x_parse_dt()
2307 pdata->vidout_inv_hs = 1; in tda1997x_parse_dt()
2309 pdata->vidout_inv_vs = 1; in tda1997x_parse_dt()
2311 pdata->vidout_inv_de = 1; in tda1997x_parse_dt()
2312 pdata->vidout_bus_width = bus_cfg.bus.parallel.bus_width; in tda1997x_parse_dt()
2315 ret = of_property_count_u32_elems(np, "nxp,vidout-portcfg"); in tda1997x_parse_dt()
2320 of_property_read_u32_index(np, "nxp,vidout-portcfg", in tda1997x_parse_dt()
2322 of_property_read_u32_index(np, "nxp,vidout-portcfg", in tda1997x_parse_dt()
2325 pdata->vidout_port_cfg[reg] = val; in tda1997x_parse_dt()
2328 v4l_err(state->client, "nxp,vidout-portcfg missing\n"); in tda1997x_parse_dt()
2329 return -EINVAL; in tda1997x_parse_dt()
2333 pdata->audout_layoutauto = true; in tda1997x_parse_dt()
2335 pdata->audout_format = AUDFMT_TYPE_DISABLED; in tda1997x_parse_dt()
2336 if (!of_property_read_string(np, "nxp,audout-format", &str)) { in tda1997x_parse_dt()
2338 pdata->audout_format = AUDFMT_TYPE_I2S; in tda1997x_parse_dt()
2340 pdata->audout_format = AUDFMT_TYPE_SPDIF; in tda1997x_parse_dt()
2342 v4l_err(state->client, "nxp,audout-format invalid\n"); in tda1997x_parse_dt()
2343 return -EINVAL; in tda1997x_parse_dt()
2345 if (!of_property_read_u32(np, "nxp,audout-layout", &v)) { in tda1997x_parse_dt()
2351 v4l_err(state->client, in tda1997x_parse_dt()
2352 "nxp,audout-layout invalid\n"); in tda1997x_parse_dt()
2353 return -EINVAL; in tda1997x_parse_dt()
2355 pdata->audout_layout = v; in tda1997x_parse_dt()
2357 if (!of_property_read_u32(np, "nxp,audout-width", &v)) { in tda1997x_parse_dt()
2363 v4l_err(state->client, in tda1997x_parse_dt()
2364 "nxp,audout-width invalid\n"); in tda1997x_parse_dt()
2365 return -EINVAL; in tda1997x_parse_dt()
2367 pdata->audout_width = v; in tda1997x_parse_dt()
2369 if (!of_property_read_u32(np, "nxp,audout-mclk-fs", &v)) { in tda1997x_parse_dt()
2379 v4l_err(state->client, in tda1997x_parse_dt()
2380 "nxp,audout-mclk-fs invalid\n"); in tda1997x_parse_dt()
2381 return -EINVAL; in tda1997x_parse_dt()
2383 pdata->audout_mclk_fs = v; in tda1997x_parse_dt()
2395 state->supplies[i].supply = tda1997x_supply_name[i]; in tda1997x_get_regulators()
2397 return devm_regulator_bulk_get(&state->client->dev, in tda1997x_get_regulators()
2399 state->supplies); in tda1997x_get_regulators()
2404 struct v4l2_subdev *sd = &state->sd; in tda1997x_identify_module() local
2409 reg = io_read(sd, REG_CMTP_REG10); in tda1997x_identify_module()
2410 state->tmdsb_clk = (reg >> 6) & 0x01; /* use tmds clock B_inv for B */ in tda1997x_identify_module()
2411 state->tmdsb_soc = (reg >> 5) & 0x01; /* tmds of input B */ in tda1997x_identify_module()
2412 state->port_30bit = (reg >> 2) & 0x03; /* 30bit vs 24bit */ in tda1997x_identify_module()
2413 state->output_2p5 = (reg >> 1) & 0x01; /* output supply 2.5v */ in tda1997x_identify_module()
2423 dev_err(&state->client->dev, "unsupported chip ID\n"); in tda1997x_identify_module()
2424 return -EIO; in tda1997x_identify_module()
2426 if (state->info->type != type) { in tda1997x_identify_module()
2427 dev_err(&state->client->dev, "chip id mismatch\n"); in tda1997x_identify_module()
2428 return -EIO; in tda1997x_identify_module()
2432 state->chip_revision = io_read(sd, REG_CMTP_REG11); in tda1997x_identify_module()
2442 /* -----------------------------------------------------------------------------
2446 /* refine sample-rate based on HDMI source */
2451 struct snd_soc_component *component = dai->component; in tda1997x_pcm_startup()
2452 struct snd_pcm_runtime *rtd = substream->runtime; in tda1997x_pcm_startup()
2455 rate = state->audio_samplerate; in tda1997x_pcm_startup()
2459 dev_err(component->dev, "failed to constrain samplerate to %dHz\n", in tda1997x_pcm_startup()
2463 dev_info(component->dev, "set samplerate constraint to %dHz\n", rate); in tda1997x_pcm_startup()
2474 .capture = {
2475 .stream_name = "Capture",
2509 struct v4l2_subdev *sd; in tda1997x_probe() local
2518 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in tda1997x_probe()
2519 return -EIO; in tda1997x_probe()
2523 return -ENOMEM; in tda1997x_probe()
2525 state->client = client; in tda1997x_probe()
2526 pdata = &state->pdata; in tda1997x_probe()
2527 if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) { in tda1997x_probe()
2530 oid = of_match_node(tda1997x_of_id, client->dev.of_node); in tda1997x_probe()
2531 state->info = oid->data; in tda1997x_probe()
2538 } else if (client->dev.platform_data) { in tda1997x_probe()
2540 client->dev.platform_data; in tda1997x_probe()
2541 state->info = in tda1997x_probe()
2542 (const struct tda1997x_chip_info *)id->driver_data; in tda1997x_probe()
2543 state->pdata = *pdata; in tda1997x_probe()
2546 ret = -ENODEV; in tda1997x_probe()
2558 mutex_init(&state->page_lock); in tda1997x_probe()
2559 mutex_init(&state->lock); in tda1997x_probe()
2560 state->page = 0xff; in tda1997x_probe()
2562 INIT_DELAYED_WORK(&state->delayed_work_enable_hpd, in tda1997x_probe()
2571 sd = &state->sd; in tda1997x_probe()
2572 v4l2_i2c_subdev_init(sd, client, &tda1997x_subdev_ops); in tda1997x_probe()
2573 snprintf(sd->name, sizeof(sd->name), "%s %d-%04x", in tda1997x_probe()
2574 id->name, i2c_adapter_id(client->adapter), in tda1997x_probe()
2575 client->addr); in tda1997x_probe()
2576 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in tda1997x_probe()
2577 sd->entity.function = MEDIA_ENT_F_DV_DECODER; in tda1997x_probe()
2578 sd->entity.ops = &tda1997x_media_ops; in tda1997x_probe()
2580 /* set allowed mbus modes based on chip, bus-type, and bus-width */ in tda1997x_probe()
2582 mbus_codes = state->mbus_codes; in tda1997x_probe()
2583 switch (state->info->type) { in tda1997x_probe()
2585 switch (pdata->vidout_bus_type) { in tda1997x_probe()
2587 switch (pdata->vidout_bus_width) { in tda1997x_probe()
2598 switch (pdata->vidout_bus_width) { in tda1997x_probe()
2613 switch (pdata->vidout_bus_type) { in tda1997x_probe()
2615 switch (pdata->vidout_bus_width) { in tda1997x_probe()
2630 switch (pdata->vidout_bus_width) { in tda1997x_probe()
2650 if (WARN_ON(i > ARRAY_SIZE(state->mbus_codes))) { in tda1997x_probe()
2651 ret = -EINVAL; in tda1997x_probe()
2656 tda1997x_setup_format(state, state->mbus_codes[0]); in tda1997x_probe()
2657 state->timings = cea1920x1080; in tda1997x_probe()
2663 state->colorimetry.colorspace = V4L2_COLORSPACE_SRGB; in tda1997x_probe()
2664 state->colorimetry.quantization = V4L2_QUANTIZATION_FULL_RANGE; in tda1997x_probe()
2667 io_write(sd, REG_MAN_SUS_HDMI_SEL, MAN_RST_HDCP | MAN_DIS_HDCP); in tda1997x_probe()
2673 if (state->chip_revision != 0) { in tda1997x_probe()
2674 io_write(sd, REG_MAN_SUS_HDMI_SEL, 0x00); in tda1997x_probe()
2675 io_write(sd, REG_VDP_CTRL, 0x1f); in tda1997x_probe()
2678 v4l_info(client, "NXP %s N%d detected\n", state->info->name, in tda1997x_probe()
2679 state->chip_revision + 1); in tda1997x_probe()
2681 pdata->vidout_bus_width, in tda1997x_probe()
2682 (pdata->vidout_bus_type == V4L2_MBUS_PARALLEL) ? in tda1997x_probe()
2685 if (pdata->audout_format) { in tda1997x_probe()
2687 pdata->audout_layout ? 2 : 8, in tda1997x_probe()
2688 audfmt_names[pdata->audout_format], in tda1997x_probe()
2689 pdata->audout_layout, in tda1997x_probe()
2690 pdata->audout_mclk_fs); in tda1997x_probe()
2693 ret = 0x34 + ((io_read(sd, REG_SLAVE_ADDR)>>4) & 0x03); in tda1997x_probe()
2694 state->client_cec = devm_i2c_new_dummy_device(&client->dev, in tda1997x_probe()
2695 client->adapter, ret); in tda1997x_probe()
2696 if (IS_ERR(state->client_cec)) { in tda1997x_probe()
2697 ret = PTR_ERR(state->client_cec); in tda1997x_probe()
2703 ret = tda1997x_core_init(sd); in tda1997x_probe()
2708 hdl = &state->hdl; in tda1997x_probe()
2715 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in tda1997x_probe()
2717 state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL, in tda1997x_probe()
2719 state->rgb_quantization_range_ctrl = v4l2_ctrl_new_std_menu(hdl, in tda1997x_probe()
2723 state->sd.ctrl_handler = hdl; in tda1997x_probe()
2724 if (hdl->error) { in tda1997x_probe()
2725 ret = hdl->error; in tda1997x_probe()
2731 state->pads[TDA1997X_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in tda1997x_probe()
2732 ret = media_entity_pads_init(&sd->entity, TDA1997X_NUM_PADS, in tda1997x_probe()
2733 state->pads); in tda1997x_probe()
2739 ret = v4l2_async_register_subdev(sd); in tda1997x_probe()
2744 if (pdata->audout_format) { in tda1997x_probe()
2747 if (pdata->audout_width == 32) in tda1997x_probe()
2751 tda1997x_audio_dai.capture.formats = formats; in tda1997x_probe()
2752 ret = devm_snd_soc_register_component(&state->client->dev, in tda1997x_probe()
2756 dev_err(&client->dev, "register audio codec failed\n"); in tda1997x_probe()
2759 dev_set_drvdata(&state->client->dev, state); in tda1997x_probe()
2760 v4l_info(state->client, "registered audio codec\n"); in tda1997x_probe()
2764 ret = devm_request_threaded_irq(&client->dev, client->irq, in tda1997x_probe()
2769 v4l_err(client, "irq%d reg failed: %d\n", client->irq, ret); in tda1997x_probe()
2776 media_entity_cleanup(&sd->entity); in tda1997x_probe()
2778 v4l2_ctrl_handler_free(&state->hdl); in tda1997x_probe()
2780 cancel_delayed_work(&state->delayed_work_enable_hpd); in tda1997x_probe()
2781 mutex_destroy(&state->page_lock); in tda1997x_probe()
2782 mutex_destroy(&state->lock); in tda1997x_probe()
2785 dev_err(&client->dev, "%s failed: %d\n", __func__, ret); in tda1997x_probe()
2792 struct v4l2_subdev *sd = i2c_get_clientdata(client); in tda1997x_remove() local
2793 struct tda1997x_state *state = to_state(sd); in tda1997x_remove()
2794 struct tda1997x_platform_data *pdata = &state->pdata; in tda1997x_remove()
2796 if (pdata->audout_format) { in tda1997x_remove()
2797 mutex_destroy(&state->audio_lock); in tda1997x_remove()
2800 disable_irq(state->client->irq); in tda1997x_remove()
2803 v4l2_async_unregister_subdev(sd); in tda1997x_remove()
2804 media_entity_cleanup(&sd->entity); in tda1997x_remove()
2805 v4l2_ctrl_handler_free(&state->hdl); in tda1997x_remove()
2806 regulator_bulk_disable(TDA1997X_NUM_SUPPLIES, state->supplies); in tda1997x_remove()
2807 cancel_delayed_work(&state->delayed_work_enable_hpd); in tda1997x_remove()
2808 mutex_destroy(&state->page_lock); in tda1997x_remove()
2809 mutex_destroy(&state->lock); in tda1997x_remove()