Lines Matching +full:x +full:- +full:rp
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * device driver for Conexant 2388x based TV cards
8 * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@kernel.org>
9 * - Multituner support
10 * - video_ioctl2 conversion
11 * - PAL/M fixes
29 #include <media/v4l2-common.h>
30 #include <media/v4l2-ioctl.h>
36 /* ------------------------------------------------------------------ */
64 #define NO_SYNC_LINE (-1U)
70 static __le32 *cx88_risc_field(__le32 *rp, struct scatterlist *sglist, in cx88_risc_field() argument
79 (*rp++) = cpu_to_le32(RISC_JUMP); in cx88_risc_field()
80 (*rp++) = 0; in cx88_risc_field()
85 *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); in cx88_risc_field()
91 offset -= sg_dma_len(sg); in cx88_risc_field()
98 if (bpl <= sg_dma_len(sg) - offset) { in cx88_risc_field()
100 *(rp++) = cpu_to_le32(RISC_WRITE | sol | in cx88_risc_field()
102 *(rp++) = cpu_to_le32(sg_dma_address(sg) + offset); in cx88_risc_field()
107 *(rp++) = cpu_to_le32(RISC_WRITE | sol | in cx88_risc_field()
108 (sg_dma_len(sg) - offset)); in cx88_risc_field()
109 *(rp++) = cpu_to_le32(sg_dma_address(sg) + offset); in cx88_risc_field()
110 todo -= (sg_dma_len(sg) - offset); in cx88_risc_field()
114 *(rp++) = cpu_to_le32(RISC_WRITE | in cx88_risc_field()
116 *(rp++) = cpu_to_le32(sg_dma_address(sg)); in cx88_risc_field()
117 todo -= sg_dma_len(sg); in cx88_risc_field()
120 *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo); in cx88_risc_field()
121 *(rp++) = cpu_to_le32(sg_dma_address(sg)); in cx88_risc_field()
127 return rp; in cx88_risc_field()
136 __le32 *rp; in cx88_risc_buffer() local
153 risc->size = instructions * 8; in cx88_risc_buffer()
154 risc->dma = 0; in cx88_risc_buffer()
155 risc->cpu = dma_alloc_coherent(&pci->dev, risc->size, &risc->dma, in cx88_risc_buffer()
157 if (!risc->cpu) in cx88_risc_buffer()
158 return -ENOMEM; in cx88_risc_buffer()
161 rp = risc->cpu; in cx88_risc_buffer()
163 rp = cx88_risc_field(rp, sglist, top_offset, 0, in cx88_risc_buffer()
166 rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200, in cx88_risc_buffer()
171 risc->jmp = rp; in cx88_risc_buffer()
172 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); in cx88_risc_buffer()
182 __le32 *rp; in cx88_risc_databuffer() local
192 risc->size = instructions * 8; in cx88_risc_databuffer()
193 risc->dma = 0; in cx88_risc_databuffer()
194 risc->cpu = dma_alloc_coherent(&pci->dev, risc->size, &risc->dma, in cx88_risc_databuffer()
196 if (!risc->cpu) in cx88_risc_databuffer()
197 return -ENOMEM; in cx88_risc_databuffer()
200 rp = risc->cpu; in cx88_risc_databuffer()
201 rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, in cx88_risc_databuffer()
205 risc->jmp = rp; in cx88_risc_databuffer()
206 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); in cx88_risc_databuffer()
224 * channel 21 (y video) - 10.0k
225 * channel 22 (u video) - 2.0k
226 * channel 23 (v video) - 2.0k
227 * channel 24 (vbi) - 4.0k
228 * channels 25+26 (audio) - 4.0k
229 * channel 28 (mpeg) - 4.0k
230 * channel 27 (audio rds)- 3.0k
237 * 0x0000 - 0x03ff CMDs / reserved
238 * 0x0400 - 0x0bff instruction queues + CDs
239 * 0x0c00 - FIFOs
350 cdt = ch->cdt; in cx88_sram_channel_setup()
351 lines = ch->fifo_size / bpl; in cx88_sram_channel_setup()
358 cx_write(cdt + 16 * i, ch->fifo_start + bpl * i); in cx88_sram_channel_setup()
361 cx_write(ch->cmds_start + 0, risc); in cx88_sram_channel_setup()
362 cx_write(ch->cmds_start + 4, cdt); in cx88_sram_channel_setup()
363 cx_write(ch->cmds_start + 8, (lines * 16) >> 3); in cx88_sram_channel_setup()
364 cx_write(ch->cmds_start + 12, ch->ctrl_start); in cx88_sram_channel_setup()
365 cx_write(ch->cmds_start + 16, 64 >> 2); in cx88_sram_channel_setup()
367 cx_write(ch->cmds_start + i, 0); in cx88_sram_channel_setup()
370 cx_write(ch->ptr1_reg, ch->fifo_start); in cx88_sram_channel_setup()
371 cx_write(ch->ptr2_reg, cdt); in cx88_sram_channel_setup()
372 cx_write(ch->cnt1_reg, (bpl >> 3) - 1); in cx88_sram_channel_setup()
373 cx_write(ch->cnt2_reg, (lines * 16) >> 3); in cx88_sram_channel_setup()
375 dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); in cx88_sram_channel_setup()
380 /* ------------------------------------------------------------------ */
412 dprintk0("0x%08x [ %s", risc, in cx88_risc_decode()
414 for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--) in cx88_risc_decode()
440 dprintk0("%s - dma channel status dump\n", ch->name); in cx88_sram_channel_dump()
442 dprintk0(" cmds: %-12s: 0x%08x\n", in cx88_sram_channel_dump()
443 name[i], cx_read(ch->cmds_start + 4 * i)); in cx88_sram_channel_dump()
445 risc = cx_read(ch->cmds_start + 4 * (i + 11)); in cx88_sram_channel_dump()
447 if (--n) in cx88_sram_channel_dump()
448 pr_cont("0x%08x [ arg #%d ]\n", risc, n); in cx88_sram_channel_dump()
453 risc = cx_read(ch->ctrl_start + 4 * i); in cx88_sram_channel_dump()
454 dprintk0(" iq %x: ", i); in cx88_sram_channel_dump()
457 risc = cx_read(ch->ctrl_start + 4 * (i + j)); in cx88_sram_channel_dump()
458 pr_cont(" iq %x: 0x%08x [ arg #%d ]\n", in cx88_sram_channel_dump()
463 dprintk0("fifo: 0x%08x -> 0x%x\n", in cx88_sram_channel_dump()
464 ch->fifo_start, ch->fifo_start + ch->fifo_size); in cx88_sram_channel_dump()
465 dprintk0("ctrl: 0x%08x -> 0x%x\n", in cx88_sram_channel_dump()
466 ch->ctrl_start, ch->ctrl_start + 6 * 16); in cx88_sram_channel_dump()
467 dprintk0(" ptr1_reg: 0x%08x\n", cx_read(ch->ptr1_reg)); in cx88_sram_channel_dump()
468 dprintk0(" ptr2_reg: 0x%08x\n", cx_read(ch->ptr2_reg)); in cx88_sram_channel_dump()
469 dprintk0(" cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg)); in cx88_sram_channel_dump()
470 dprintk0(" cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg)); in cx88_sram_channel_dump()
486 dprintk0("%s [0x%x]", tag, bits); in cx88_print_irqbits()
502 /* ------------------------------------------------------------------ */
515 status, core->pci_irqmask); in cx88_core_irq()
525 buf = list_entry(q->active.next, in cx88_wakeup()
527 buf->vb.vb2_buf.timestamp = ktime_get_ns(); in cx88_wakeup()
528 buf->vb.field = core->field; in cx88_wakeup()
529 buf->vb.sequence = q->count++; in cx88_wakeup()
530 list_del(&buf->list); in cx88_wakeup()
531 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); in cx88_wakeup()
608 /* Reset on-board parts */ in cx88_reset()
617 /* ------------------------------------------------------------------ */
655 return 28636360; // 3.57954545 MHz +/- 10 Hz in norm_fsc8()
664 return 35468950; // 4.43361875 MHz +/- 5 Hz in norm_fsc8()
685 unsigned int swidth = norm_swidth(core->tvnorm); in cx88_set_scale()
686 unsigned int sheight = norm_maxh(core->tvnorm); in cx88_set_scale()
692 v4l2_norm_to_name(core->tvnorm)); in cx88_set_scale()
697 value = (width * norm_hdelay(core->tvnorm)) / swidth; in cx88_set_scale()
701 dprintk(1, "set_scale: hdelay 0x%04x (width %d)\n", value, swidth); in cx88_set_scale()
703 value = (swidth * 4096 / width) - 4096; in cx88_set_scale()
706 dprintk(1, "set_scale: hscale 0x%04x\n", value); in cx88_set_scale()
710 dprintk(1, "set_scale: hactive 0x%04x\n", width); in cx88_set_scale()
713 cx_write(MO_VDELAY_EVEN, norm_vdelay(core->tvnorm)); in cx88_set_scale()
714 cx_write(MO_VDELAY_ODD, norm_vdelay(core->tvnorm)); in cx88_set_scale()
715 dprintk(1, "set_scale: vdelay 0x%04x\n", norm_vdelay(core->tvnorm)); in cx88_set_scale()
717 value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff; in cx88_set_scale()
720 dprintk(1, "set_scale: vscale 0x%04x\n", value); in cx88_set_scale()
724 dprintk(1, "set_scale: vactive 0x%04x\n", sheight); in cx88_set_scale()
729 if (core->tvnorm & V4L2_STD_SECAM) { in cx88_set_scale()
733 if (INPUT(core->input).type == CX88_VMUX_SVIDEO) in cx88_set_scale()
738 value |= (1 << 0); // 3-tap interpolation in cx88_set_scale()
740 value |= (1 << 1); // 5-tap interpolation in cx88_set_scale()
746 dprintk(1, "set_scale: filter 0x%04x\n", value); in cx88_set_scale()
771 return -1; in set_pll()
774 dprintk(1, "set_pll: MO_PLL_REG 0x%08x [old=0x%08x,freq=%d]\n", in set_pll()
788 return -1; in set_pll()
793 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */ in cx88_start_audio_dma()
831 v4l2_std_id norm = core->tvnorm; in set_tvaudio()
833 if (INPUT(core->input).type != CX88_VMUX_TELEVISION && in set_tvaudio()
834 INPUT(core->input).type != CX88_VMUX_CABLE) in set_tvaudio()
838 core->tvaudio = WW_BG; in set_tvaudio()
841 core->tvaudio = WW_DK; in set_tvaudio()
844 core->tvaudio = WW_I; in set_tvaudio()
847 core->tvaudio = WW_L; in set_tvaudio()
851 core->tvaudio = WW_BG; in set_tvaudio()
854 core->tvaudio = WW_DK; in set_tvaudio()
858 core->tvaudio = WW_BTSC; in set_tvaudio()
861 core->tvaudio = WW_EIAJ; in set_tvaudio()
865 v4l2_norm_to_name(core->tvnorm)); in set_tvaudio()
866 core->tvaudio = WW_NONE; in set_tvaudio()
875 * This should be needed only on cx88-alsa. It seems that some cx88 chips have in set_tvaudio()
892 if (norm == core->tvnorm) in cx88_set_tvnorm()
894 if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || in cx88_set_tvnorm()
895 vb2_is_busy(&core->v4ldev->vb2_vbiq))) in cx88_set_tvnorm()
896 return -EBUSY; in cx88_set_tvnorm()
897 if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) in cx88_set_tvnorm()
898 return -EBUSY; in cx88_set_tvnorm()
899 core->tvnorm = norm; in cx88_set_tvnorm()
939 v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock, in cx88_set_tvnorm()
943 dprintk(1, "set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", in cx88_set_tvnorm()
952 // FIXME: as-is from DScaler in cx88_set_tvnorm()
953 dprintk(1, "set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", in cx88_set_tvnorm()
960 dprintk(1, "set_tvnorm: MO_SCONV_REG 0x%08x [old=0x%08x]\n", in cx88_set_tvnorm()
967 dprintk(1, "set_tvnorm: MO_SUB_STEP 0x%08x [old=0x%08x]\n", in cx88_set_tvnorm()
974 dprintk(1, "set_tvnorm: MO_SUB_STEP_DR 0x%08x [old=0x%08x]\n", in cx88_set_tvnorm()
982 "set_tvnorm: MO_AGC_BURST 0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n", in cx88_set_tvnorm()
992 "set_tvnorm: MO_HTOTAL 0x%08x [old=0x%08x,htotal=%d]\n", in cx88_set_tvnorm()
1013 v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM); in cx88_set_tvnorm()
1020 /* ------------------------------------------------------------------ */
1036 vfd->v4l2_dev = &core->v4l2_dev; in cx88_vdev_init()
1037 vfd->dev_parent = &pci->dev; in cx88_vdev_init()
1038 vfd->release = video_device_release_empty; in cx88_vdev_init()
1039 vfd->lock = &core->lock; in cx88_vdev_init()
1040 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", in cx88_vdev_init()
1041 core->name, type, core->board.name); in cx88_vdev_init()
1051 if (pci->bus->number != core->pci_bus) in cx88_core_get()
1053 if (PCI_SLOT(pci->devfn) != core->pci_slot) in cx88_core_get()
1060 refcount_inc(&core->refcount); in cx88_core_get()
1068 list_add_tail(&core->devlist, &cx88_devlist); in cx88_core_get()
1081 if (!refcount_dec_and_test(&core->refcount)) in cx88_core_put()
1086 if (core->i2c_rc == 0) { in cx88_core_put()
1087 i2c_unregister_device(core->i2c_rtc); in cx88_core_put()
1088 i2c_del_adapter(&core->i2c_adap); in cx88_core_put()
1090 list_del(&core->devlist); in cx88_core_put()
1091 iounmap(core->lmmio); in cx88_core_put()
1092 cx88_devcount--; in cx88_core_put()
1094 v4l2_ctrl_handler_free(&core->video_hdl); in cx88_core_put()
1095 v4l2_ctrl_handler_free(&core->audio_hdl); in cx88_core_put()
1096 v4l2_device_unregister(&core->v4l2_dev); in cx88_core_put()