22 #define DSS_SUBSYS_NAME "VENC"
24 #include <linux/kernel.h>
25 #include <linux/module.h>
32 #include <linux/string.h>
44 #define VENC_REV_ID 0x00
45 #define VENC_STATUS 0x04
46 #define VENC_F_CONTROL 0x08
47 #define VENC_VIDOUT_CTRL 0x10
48 #define VENC_SYNC_CTRL 0x14
49 #define VENC_LLEN 0x1C
50 #define VENC_FLENS 0x20
51 #define VENC_HFLTR_CTRL 0x24
52 #define VENC_CC_CARR_WSS_CARR 0x28
53 #define VENC_C_PHASE 0x2C
54 #define VENC_GAIN_U 0x30
55 #define VENC_GAIN_V 0x34
56 #define VENC_GAIN_Y 0x38
57 #define VENC_BLACK_LEVEL 0x3C
58 #define VENC_BLANK_LEVEL 0x40
59 #define VENC_X_COLOR 0x44
60 #define VENC_M_CONTROL 0x48
61 #define VENC_BSTAMP_WSS_DATA 0x4C
62 #define VENC_S_CARR 0x50
63 #define VENC_LINE21 0x54
64 #define VENC_LN_SEL 0x58
65 #define VENC_L21__WC_CTL 0x5C
66 #define VENC_HTRIGGER_VTRIGGER 0x60
67 #define VENC_SAVID__EAVID 0x64
68 #define VENC_FLEN__FAL 0x68
69 #define VENC_LAL__PHASE_RESET 0x6C
70 #define VENC_HS_INT_START_STOP_X 0x70
71 #define VENC_HS_EXT_START_STOP_X 0x74
72 #define VENC_VS_INT_START_X 0x78
73 #define VENC_VS_INT_STOP_X__VS_INT_START_Y 0x7C
74 #define VENC_VS_INT_STOP_Y__VS_EXT_START_X 0x80
75 #define VENC_VS_EXT_STOP_X__VS_EXT_START_Y 0x84
76 #define VENC_VS_EXT_STOP_Y 0x88
77 #define VENC_AVID_START_STOP_X 0x90
78 #define VENC_AVID_START_STOP_Y 0x94
79 #define VENC_FID_INT_START_X__FID_INT_START_Y 0xA0
80 #define VENC_FID_INT_OFFSET_Y__FID_EXT_START_X 0xA4
81 #define VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y 0xA8
82 #define VENC_TVDETGP_INT_START_STOP_X 0xB0
83 #define VENC_TVDETGP_INT_START_STOP_Y 0xB4
84 #define VENC_GEN_CTRL 0xB8
85 #define VENC_OUTPUT_CONTROL 0xC4
86 #define VENC_OUTPUT_TEST 0xC8
87 #define VENC_DAC_B__DAC_C 0xC8
132 static const struct venc_config venc_config_pal_trm = {
139 .cc_carr_wss_carr = 0x2F7225ED,
148 .bstamp_wss_data = 0x3F,
149 .s_carr = 0x2A098ACB,
151 .ln_sel = 0x01290015,
152 .l21__wc_ctl = 0x0000F603,
153 .htrigger_vtrigger = 0,
155 .savid__eavid = 0x06A70108,
156 .flen__fal = 0x00180270,
157 .lal__phase_reset = 0x00040135,
158 .hs_int_start_stop_x = 0x00880358,
159 .hs_ext_start_stop_x = 0x000F035F,
160 .vs_int_start_x = 0x01A70000,
161 .vs_int_stop_x__vs_int_start_y = 0x000001A7,
162 .vs_int_stop_y__vs_ext_start_x = 0x01AF0000,
163 .vs_ext_stop_x__vs_ext_start_y = 0x000101AF,
164 .vs_ext_stop_y = 0x00000025,
165 .avid_start_stop_x = 0x03530083,
166 .avid_start_stop_y = 0x026C002E,
167 .fid_int_start_x__fid_int_start_y = 0x0001008A,
168 .fid_int_offset_y__fid_ext_start_x = 0x002E0138,
169 .fid_ext_start_y__fid_ext_offset_y = 0x01380001,
171 .tvdetgp_int_start_stop_x = 0x00140001,
172 .tvdetgp_int_start_stop_y = 0x00010001,
173 .gen_ctrl = 0x00FF0000,
177 static const struct venc_config venc_config_ntsc_trm = {
184 .cc_carr_wss_carr = 0x043F2631,
193 .bstamp_wss_data = 0x38,
194 .s_carr = 0x21F07C1F,
196 .ln_sel = 0x01310011,
197 .l21__wc_ctl = 0x0000F003,
198 .htrigger_vtrigger = 0,
200 .savid__eavid = 0x069300F4,
201 .flen__fal = 0x0016020C,
202 .lal__phase_reset = 0x00060107,
203 .hs_int_start_stop_x = 0x008E0350,
204 .hs_ext_start_stop_x = 0x000F0359,
205 .vs_int_start_x = 0x01A00000,
206 .vs_int_stop_x__vs_int_start_y = 0x020701A0,
207 .vs_int_stop_y__vs_ext_start_x = 0x01AC0024,
208 .vs_ext_stop_x__vs_ext_start_y = 0x020D01AC,
209 .vs_ext_stop_y = 0x00000006,
210 .avid_start_stop_x = 0x03480078,
211 .avid_start_stop_y = 0x02060024,
212 .fid_int_start_x__fid_int_start_y = 0x0001008A,
213 .fid_int_offset_y__fid_ext_start_x = 0x01AC0106,
214 .fid_ext_start_y__fid_ext_offset_y = 0x01060006,
216 .tvdetgp_int_start_stop_x = 0x00140001,
217 .tvdetgp_int_start_stop_y = 0x00010001,
218 .gen_ctrl = 0x00F90000,
221 static const struct venc_config venc_config_pal_bdghi = {
229 .htrigger_vtrigger = 0,
230 .tvdetgp_int_start_stop_x = 0x00140001,
231 .tvdetgp_int_start_stop_y = 0x00010001,
232 .gen_ctrl = 0x00FB0000,
236 .cc_carr_wss_carr = 0x2F7625ED,
243 .m_control = 0<<2 | 1<<1,
244 .bstamp_wss_data = 0x42,
245 .s_carr = 0x2a098acb,
246 .l21__wc_ctl = 0<<13 | 0x16<<8 | 0<<0,
247 .savid__eavid = 0x06A70108,
248 .flen__fal = 23<<16 | 624<<0,
249 .lal__phase_reset = 2<<17 | 310<<0,
250 .hs_int_start_stop_x = 0x00920358,
251 .hs_ext_start_stop_x = 0x000F035F,
252 .vs_int_start_x = 0x1a7<<16,
253 .vs_int_stop_x__vs_int_start_y = 0x000601A7,
254 .vs_int_stop_y__vs_ext_start_x = 0x01AF0036,
255 .vs_ext_stop_x__vs_ext_start_y = 0x27101af,
256 .vs_ext_stop_y = 0x05,
257 .avid_start_stop_x = 0x03530082,
258 .avid_start_stop_y = 0x0270002E,
259 .fid_int_start_x__fid_int_start_y = 0x0005008A,
260 .fid_int_offset_y__fid_ext_start_x = 0x002E0138,
261 .fid_ext_start_y__fid_ext_offset_y = 0x01380005,
267 .pixel_clock = 13500,
282 .pixel_clock = 13500,
310 static inline void venc_write_reg(
int idx,
u32 val)
315 static inline u32 venc_read_reg(
int idx)
323 DSSDBG(
"write venc conf\n");
377 static void venc_reset(
void)
384 DSSERR(
"Failed to reset venc\n");
389 #ifdef CONFIG_OMAP2_DSS_SLEEP_AFTER_VENC_RESET
396 static int venc_runtime_get(
void)
400 DSSDBG(
"venc_runtime_get\n");
402 r = pm_runtime_get_sync(&venc.pdev->dev);
404 return r < 0 ? r : 0;
407 static void venc_runtime_put(
void)
411 DSSDBG(
"venc_runtime_put\n");
413 r = pm_runtime_put_sync(&venc.pdev->dev);
417 static const struct venc_config *venc_timings_to_config(
420 if (
memcmp(&omap_dss_pal_timings, timings,
sizeof(*timings)) == 0)
421 return &venc_config_pal_trm;
423 if (
memcmp(&omap_dss_ntsc_timings, timings,
sizeof(*timings)) == 0)
424 return &venc_config_ntsc_trm;
436 r = venc_runtime_get();
441 venc_write_config(venc_timings_to_config(&venc.timings));
451 l |= (1 << 0) | (1 << 2);
453 if (venc.invert_polarity ==
false)
506 DSSDBG(
"venc_display_enable\n");
511 DSSERR(
"Failed to enable display: no output/manager\n");
518 DSSERR(
"failed to start device\n");
526 r = venc_power_on(dssdev);
546 DSSDBG(
"venc_display_disable\n");
550 venc_power_off(dssdev);
563 DSSDBG(
"venc_set_timings\n");
568 if (
memcmp(&venc.timings, timings,
sizeof(*timings)))
571 venc.timings = *timings;
579 DSSDBG(
"venc_check_timings\n");
581 if (
memcmp(&omap_dss_pal_timings, timings,
sizeof(*timings)) == 0)
584 if (
memcmp(&omap_dss_ntsc_timings, timings,
sizeof(*timings)) == 0)
593 return (venc.wss_data >> 8) ^ 0xfffff;
605 config = venc_timings_to_config(&venc.timings);
608 venc.wss_data = (wss ^ 0xfffff) << 8;
610 r = venc_runtime_get();
649 if (venc.vdda_dac_reg ==
NULL) {
654 if (IS_ERR(vdda_dac)) {
655 DSSERR(
"can't get VDDA_DAC regulator\n");
656 return PTR_ERR(vdda_dac);
659 venc.vdda_dac_reg = vdda_dac;
665 static void venc_dump_regs(
struct seq_file *
s)
667 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r))
669 if (venc_runtime_get())
726 DSSERR(
"can't get tv_dac_clk\n");
733 venc.tv_dac_clk = clk;
738 static void venc_put_clocks(
void)
759 if (def_dssdev ==
NULL)
762 if (def_disp_name !=
NULL &&
778 plat_dssdev = venc_find_dssdev(vencdev);
791 r = venc_init_display(dssdev);
793 DSSERR(
"device %s init failed: %d\n", dssdev->
name, r);
800 DSSERR(
"device %s register failed: %d\n", dssdev->
name, r);
839 DSSERR(
"can't get IORESOURCE_MEM VENC\n");
844 resource_size(venc_mem));
846 DSSERR(
"can't ioremap VENC\n");
850 r = venc_get_clocks(pdev);
856 r = venc_runtime_get();
858 goto err_runtime_get;
861 dev_dbg(&pdev->
dev,
"OMAP VENC rev %d\n", rev_id);
871 venc_init_output(pdev);
873 venc_probe_pdata(pdev);
879 pm_runtime_disable(&pdev->
dev);
888 if (venc.vdda_dac_reg !=
NULL) {
890 venc.vdda_dac_reg =
NULL;
895 venc_uninit_output(pdev);
897 pm_runtime_disable(&pdev->
dev);
903 static int venc_runtime_suspend(
struct device *
dev)
906 clk_disable_unprepare(venc.tv_dac_clk);
913 static int venc_runtime_resume(
struct device *dev)
922 clk_prepare_enable(venc.tv_dac_clk);
927 static const struct dev_pm_ops venc_pm_ops = {
928 .runtime_suspend = venc_runtime_suspend,
929 .runtime_resume = venc_runtime_resume,
933 .remove =
__exit_p(omap_venchw_remove),
935 .name =
"omapdss_venc",