Lines Matching full:sd
53 struct v4l2_subdev sd; member
65 static inline struct venc_state *to_state(struct v4l2_subdev *sd) in to_state() argument
67 return container_of(sd, struct venc_state, sd); in to_state()
70 static inline u32 venc_read(struct v4l2_subdev *sd, u32 offset) in venc_read() argument
72 struct venc_state *venc = to_state(sd); in venc_read()
77 static inline u32 venc_write(struct v4l2_subdev *sd, u32 offset, u32 val) in venc_write() argument
79 struct venc_state *venc = to_state(sd); in venc_write()
86 static inline u32 venc_modify(struct v4l2_subdev *sd, u32 offset, in venc_modify() argument
89 u32 new_val = (venc_read(sd, offset) & ~mask) | (val & mask); in venc_modify()
91 venc_write(sd, offset, new_val); in venc_modify()
96 static inline u32 vdaccfg_write(struct v4l2_subdev *sd, u32 val) in vdaccfg_write() argument
98 struct venc_state *venc = to_state(sd); in vdaccfg_write()
111 static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index) in venc_set_dac() argument
115 v4l2_dbg(debug, 1, sd, "Setting output to Composite\n"); in venc_set_dac()
116 venc_write(sd, VENC_DACSEL, 0); in venc_set_dac()
119 v4l2_dbg(debug, 1, sd, "Setting output to Component\n"); in venc_set_dac()
120 venc_write(sd, VENC_DACSEL, VDAC_COMPONENT); in venc_set_dac()
123 v4l2_dbg(debug, 1, sd, "Setting output to S-video\n"); in venc_set_dac()
124 venc_write(sd, VENC_DACSEL, VDAC_S_VIDEO); in venc_set_dac()
133 static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable) in venc_enabledigitaloutput() argument
135 struct venc_state *venc = to_state(sd); in venc_enabledigitaloutput()
137 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n"); in venc_enabledigitaloutput()
140 venc_write(sd, VENC_VMOD, 0); in venc_enabledigitaloutput()
141 venc_write(sd, VENC_CVBS, 0); in venc_enabledigitaloutput()
142 venc_write(sd, VENC_LCDOUT, 0); in venc_enabledigitaloutput()
143 venc_write(sd, VENC_HSPLS, 0); in venc_enabledigitaloutput()
144 venc_write(sd, VENC_HSTART, 0); in venc_enabledigitaloutput()
145 venc_write(sd, VENC_HVALID, 0); in venc_enabledigitaloutput()
146 venc_write(sd, VENC_HINT, 0); in venc_enabledigitaloutput()
147 venc_write(sd, VENC_VSPLS, 0); in venc_enabledigitaloutput()
148 venc_write(sd, VENC_VSTART, 0); in venc_enabledigitaloutput()
149 venc_write(sd, VENC_VVALID, 0); in venc_enabledigitaloutput()
150 venc_write(sd, VENC_VINT, 0); in venc_enabledigitaloutput()
151 venc_write(sd, VENC_YCCCTL, 0); in venc_enabledigitaloutput()
152 venc_write(sd, VENC_DACSEL, 0); in venc_enabledigitaloutput()
155 venc_write(sd, VENC_VMOD, 0); in venc_enabledigitaloutput()
157 venc_write(sd, VENC_VIDCTL, 0x141); in venc_enabledigitaloutput()
160 venc_write(sd, VENC_SYNCCTL, 0); in venc_enabledigitaloutput()
163 venc_write(sd, VENC_DCLKCTL, 0); in venc_enabledigitaloutput()
164 venc_write(sd, VENC_DRGBX1, 0x0000057C); in venc_enabledigitaloutput()
167 venc_write(sd, VENC_LCDOUT, 0); in venc_enabledigitaloutput()
169 venc_write(sd, VENC_CMPNT, 0x100); in venc_enabledigitaloutput()
170 venc_write(sd, VENC_HSPLS, 0); in venc_enabledigitaloutput()
171 venc_write(sd, VENC_HINT, 0); in venc_enabledigitaloutput()
172 venc_write(sd, VENC_HSTART, 0); in venc_enabledigitaloutput()
173 venc_write(sd, VENC_HVALID, 0); in venc_enabledigitaloutput()
175 venc_write(sd, VENC_VSPLS, 0); in venc_enabledigitaloutput()
176 venc_write(sd, VENC_VINT, 0); in venc_enabledigitaloutput()
177 venc_write(sd, VENC_VSTART, 0); in venc_enabledigitaloutput()
178 venc_write(sd, VENC_VVALID, 0); in venc_enabledigitaloutput()
180 venc_write(sd, VENC_HSDLY, 0); in venc_enabledigitaloutput()
181 venc_write(sd, VENC_VSDLY, 0); in venc_enabledigitaloutput()
183 venc_write(sd, VENC_YCCCTL, 0); in venc_enabledigitaloutput()
184 venc_write(sd, VENC_VSTARTA, 0); in venc_enabledigitaloutput()
187 venc_write(sd, VENC_OSDCLK0, 1); in venc_enabledigitaloutput()
188 venc_write(sd, VENC_OSDCLK1, 2); in venc_enabledigitaloutput()
216 static int venc_set_ntsc(struct v4l2_subdev *sd) in venc_set_ntsc() argument
218 struct venc_state *venc = to_state(sd); in venc_set_ntsc()
221 v4l2_dbg(debug, 2, sd, "venc_set_ntsc\n"); in venc_set_ntsc()
223 /* Setup clock at VPSS & VENC for SD */ in venc_set_ntsc()
229 venc_enabledigitaloutput(sd, 0); in venc_set_ntsc()
232 venc_write(sd, VENC_CLKCTL, 0x01); in venc_set_ntsc()
233 venc_write(sd, VENC_VIDCTL, 0); in venc_set_ntsc()
234 vdaccfg_write(sd, VDAC_CONFIG_SD_V3); in venc_set_ntsc()
236 venc_write(sd, VENC_CLKCTL, 0x01); in venc_set_ntsc()
237 venc_write(sd, VENC_VIDCTL, 0); in venc_set_ntsc()
238 vdaccfg_write(sd, VDAC_CONFIG_SD_V2); in venc_set_ntsc()
241 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); in venc_set_ntsc()
243 venc_write(sd, VENC_YCCCTL, 0x1); in venc_set_ntsc()
244 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAFRQ); in venc_set_ntsc()
245 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAUPS); in venc_set_ntsc()
248 venc_write(sd, VENC_VMOD, 0); in venc_set_ntsc()
249 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_ntsc()
251 venc_modify(sd, VENC_VMOD, (0 << VENC_VMOD_VMD), VENC_VMOD_VMD); in venc_set_ntsc()
252 venc_modify(sd, VENC_VMOD, (0 << VENC_VMOD_TVTYP_SHIFT), in venc_set_ntsc()
254 venc_write(sd, VENC_DACTST, 0x0); in venc_set_ntsc()
255 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_ntsc()
263 static int venc_set_pal(struct v4l2_subdev *sd) in venc_set_pal() argument
265 struct venc_state *venc = to_state(sd); in venc_set_pal()
267 v4l2_dbg(debug, 2, sd, "venc_set_pal\n"); in venc_set_pal()
269 /* Setup clock at VPSS & VENC for SD */ in venc_set_pal()
275 venc_enabledigitaloutput(sd, 0); in venc_set_pal()
278 venc_write(sd, VENC_CLKCTL, 0x1); in venc_set_pal()
279 venc_write(sd, VENC_VIDCTL, 0); in venc_set_pal()
280 vdaccfg_write(sd, VDAC_CONFIG_SD_V3); in venc_set_pal()
282 venc_write(sd, VENC_CLKCTL, 0x1); in venc_set_pal()
283 venc_write(sd, VENC_VIDCTL, 0); in venc_set_pal()
284 vdaccfg_write(sd, VDAC_CONFIG_SD_V2); in venc_set_pal()
287 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); in venc_set_pal()
289 venc_write(sd, VENC_YCCCTL, 0x1); in venc_set_pal()
292 venc_modify(sd, VENC_SYNCCTL, 1 << VENC_SYNCCTL_OVD_SHIFT, in venc_set_pal()
294 venc_write(sd, VENC_VMOD, 0); in venc_set_pal()
295 venc_modify(sd, VENC_VMOD, in venc_set_pal()
298 venc_modify(sd, VENC_VMOD, in venc_set_pal()
300 venc_modify(sd, VENC_VMOD, in venc_set_pal()
303 venc_write(sd, VENC_DACTST, 0x0); in venc_set_pal()
304 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_pal()
315 static int venc_set_480p59_94(struct v4l2_subdev *sd) in venc_set_480p59_94() argument
317 struct venc_state *venc = to_state(sd); in venc_set_480p59_94()
320 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n"); in venc_set_480p59_94()
325 /* Setup clock at VPSS & VENC for SD */ in venc_set_480p59_94()
330 venc_enabledigitaloutput(sd, 0); in venc_set_480p59_94()
333 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_set_480p59_94()
334 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_480p59_94()
335 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_480p59_94()
338 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, in venc_set_480p59_94()
340 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, in venc_set_480p59_94()
344 venc_write(sd, VENC_VMOD, 0); in venc_set_480p59_94()
345 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_480p59_94()
347 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_480p59_94()
348 venc_modify(sd, VENC_VMOD, (HDTV_525P << VENC_VMOD_TVTYP_SHIFT), in venc_set_480p59_94()
350 venc_modify(sd, VENC_VMOD, VENC_VMOD_VDMD_YCBCR8 << in venc_set_480p59_94()
353 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_480p59_94()
363 static int venc_set_576p50(struct v4l2_subdev *sd) in venc_set_576p50() argument
365 struct venc_state *venc = to_state(sd); in venc_set_576p50()
368 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n"); in venc_set_576p50()
373 /* Setup clock at VPSS & VENC for SD */ in venc_set_576p50()
378 venc_enabledigitaloutput(sd, 0); in venc_set_576p50()
381 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_set_576p50()
383 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_576p50()
384 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_576p50()
387 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, in venc_set_576p50()
389 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, in venc_set_576p50()
393 venc_write(sd, VENC_VMOD, 0); in venc_set_576p50()
394 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_576p50()
396 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_576p50()
397 venc_modify(sd, VENC_VMOD, (HDTV_625P << VENC_VMOD_TVTYP_SHIFT), in venc_set_576p50()
400 venc_modify(sd, VENC_VMOD, VENC_VMOD_VDMD_YCBCR8 << in venc_set_576p50()
402 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_576p50()
410 static int venc_set_720p60_internal(struct v4l2_subdev *sd) in venc_set_720p60_internal() argument
412 struct venc_state *venc = to_state(sd); in venc_set_720p60_internal()
419 venc_enabledigitaloutput(sd, 0); in venc_set_720p60_internal()
421 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_720p60_internal()
422 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_720p60_internal()
424 venc_write(sd, VENC_VMOD, 0); in venc_set_720p60_internal()
426 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_720p60_internal()
428 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_720p60_internal()
429 venc_modify(sd, VENC_VMOD, (HDTV_720P << VENC_VMOD_TVTYP_SHIFT), in venc_set_720p60_internal()
431 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_720p60_internal()
432 venc_write(sd, VENC_XHINTVL, 0); in venc_set_720p60_internal()
439 static int venc_set_1080i30_internal(struct v4l2_subdev *sd) in venc_set_1080i30_internal() argument
441 struct venc_state *venc = to_state(sd); in venc_set_1080i30_internal()
448 venc_enabledigitaloutput(sd, 0); in venc_set_1080i30_internal()
450 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_1080i30_internal()
451 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_1080i30_internal()
454 venc_write(sd, VENC_VMOD, 0); in venc_set_1080i30_internal()
456 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_1080i30_internal()
458 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_1080i30_internal()
459 venc_modify(sd, VENC_VMOD, (HDTV_1080I << VENC_VMOD_TVTYP_SHIFT), in venc_set_1080i30_internal()
461 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_1080i30_internal()
462 venc_write(sd, VENC_XHINTVL, 0); in venc_set_1080i30_internal()
466 static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm) in venc_s_std_output() argument
468 v4l2_dbg(debug, 1, sd, "venc_s_std_output\n"); in venc_s_std_output()
471 return venc_set_ntsc(sd); in venc_s_std_output()
473 return venc_set_pal(sd); in venc_s_std_output()
478 static int venc_s_dv_timings(struct v4l2_subdev *sd, in venc_s_dv_timings() argument
481 struct venc_state *venc = to_state(sd); in venc_s_dv_timings()
485 v4l2_dbg(debug, 1, sd, "venc_s_dv_timings\n"); in venc_s_dv_timings()
488 return venc_set_576p50(sd); in venc_s_dv_timings()
490 return venc_set_480p59_94(sd); in venc_s_dv_timings()
494 ret = venc_set_720p60_internal(sd); in venc_s_dv_timings()
496 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_s_dv_timings()
501 ret = venc_set_1080i30_internal(sd); in venc_s_dv_timings()
503 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_s_dv_timings()
509 static int venc_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, in venc_s_routing() argument
512 struct venc_state *venc = to_state(sd); in venc_s_routing()
515 v4l2_dbg(debug, 1, sd, "venc_s_routing\n"); in venc_s_routing()
517 ret = venc_set_dac(sd, output); in venc_s_routing()
524 static long venc_ioctl(struct v4l2_subdev *sd, in venc_ioctl() argument
532 val = venc_read(sd, VENC_VSTAT); in venc_ioctl()
537 v4l2_err(sd, "Wrong IOCTL cmd\n"); in venc_ioctl()
559 static int venc_initialize(struct v4l2_subdev *sd) in venc_initialize() argument
561 struct venc_state *venc = to_state(sd); in venc_initialize()
568 ret = venc_s_routing(sd, 0, venc->output, 0); in venc_initialize()
570 v4l2_err(sd, "Error setting output during init\n"); in venc_initialize()
574 ret = venc_s_std_output(sd, venc->std); in venc_initialize()
576 v4l2_err(sd, "Error setting std during init\n"); in venc_initialize()
604 v4l2_subdev_init(&venc->sd, &venc_ops); in venc_sub_dev_init()
606 strscpy(venc->sd.name, venc_name, sizeof(venc->sd.name)); in venc_sub_dev_init()
607 if (v4l2_device_register_subdev(v4l2_dev, &venc->sd) < 0) { in venc_sub_dev_init()
612 if (venc_initialize(&venc->sd)) { in venc_sub_dev_init()
618 return &venc->sd; in venc_sub_dev_init()