Lines Matching +full:risc +full:- +full:v
1 // SPDX-License-Identifier: GPL-2.0-or-later
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)
91 offset -= sg_dma_len(sg); in cx88_risc_field()
98 if (bpl <= sg_dma_len(sg) - offset) { in cx88_risc_field()
108 (sg_dma_len(sg) - offset)); in cx88_risc_field()
110 todo -= (sg_dma_len(sg) - offset); in cx88_risc_field()
117 todo -= sg_dma_len(sg); in cx88_risc_field()
130 int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, in cx88_risc_buffer() argument
145 * estimate risc mem: worst case is one write per page border + in cx88_risc_buffer()
153 risc->size = instructions * 8; in cx88_risc_buffer()
154 risc->dma = 0; in cx88_risc_buffer()
155 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); in cx88_risc_buffer()
156 if (!risc->cpu) in cx88_risc_buffer()
157 return -ENOMEM; in cx88_risc_buffer()
159 /* write risc instructions */ in cx88_risc_buffer()
160 rp = risc->cpu; in cx88_risc_buffer()
170 risc->jmp = rp; in cx88_risc_buffer()
171 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); in cx88_risc_buffer()
176 int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, in cx88_risc_databuffer() argument
184 * estimate risc mem: worst case is one write per page border + in cx88_risc_databuffer()
191 risc->size = instructions * 8; in cx88_risc_databuffer()
192 risc->dma = 0; in cx88_risc_databuffer()
193 risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); in cx88_risc_databuffer()
194 if (!risc->cpu) in cx88_risc_databuffer()
195 return -ENOMEM; in cx88_risc_databuffer()
197 /* write risc instructions */ in cx88_risc_databuffer()
198 rp = risc->cpu; in cx88_risc_databuffer()
203 risc->jmp = rp; in cx88_risc_databuffer()
204 WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); in cx88_risc_databuffer()
214 * we are going to put all thr risc programs into host memory, so we
222 * channel 21 (y video) - 10.0k
223 * channel 22 (u video) - 2.0k
224 * channel 23 (v video) - 2.0k
225 * channel 24 (vbi) - 4.0k
226 * channels 25+26 (audio) - 4.0k
227 * channel 28 (mpeg) - 4.0k
228 * channel 27 (audio rds)- 3.0k
235 * 0x0000 - 0x03ff CMDs / reserved
236 * 0x0400 - 0x0bff instruction queues + CDs
237 * 0x0c00 - FIFOs
266 .name = "video v",
342 unsigned int bpl, u32 risc) in cx88_sram_channel_setup() argument
348 cdt = ch->cdt; in cx88_sram_channel_setup()
349 lines = ch->fifo_size / bpl; in cx88_sram_channel_setup()
356 cx_write(cdt + 16 * i, ch->fifo_start + bpl * i); in cx88_sram_channel_setup()
359 cx_write(ch->cmds_start + 0, risc); in cx88_sram_channel_setup()
360 cx_write(ch->cmds_start + 4, cdt); in cx88_sram_channel_setup()
361 cx_write(ch->cmds_start + 8, (lines * 16) >> 3); in cx88_sram_channel_setup()
362 cx_write(ch->cmds_start + 12, ch->ctrl_start); in cx88_sram_channel_setup()
363 cx_write(ch->cmds_start + 16, 64 >> 2); in cx88_sram_channel_setup()
365 cx_write(ch->cmds_start + i, 0); in cx88_sram_channel_setup()
368 cx_write(ch->ptr1_reg, ch->fifo_start); in cx88_sram_channel_setup()
369 cx_write(ch->ptr2_reg, cdt); in cx88_sram_channel_setup()
370 cx_write(ch->cnt1_reg, (bpl >> 3) - 1); in cx88_sram_channel_setup()
371 cx_write(ch->cnt2_reg, (lines * 16) >> 3); in cx88_sram_channel_setup()
373 dprintk(2, "sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines); in cx88_sram_channel_setup()
378 /* ------------------------------------------------------------------ */
381 static int cx88_risc_decode(u32 risc) in cx88_risc_decode() argument
410 dprintk0("0x%08x [ %s", risc, in cx88_risc_decode()
411 instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); in cx88_risc_decode()
412 for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--) in cx88_risc_decode()
413 if (risc & (1 << (i + 12))) in cx88_risc_decode()
415 pr_cont(" count=%d ]\n", risc & 0xfff); in cx88_risc_decode()
416 return incr[risc >> 28] ? incr[risc >> 28] : 1; in cx88_risc_decode()
423 "initial risc", in cx88_sram_channel_dump()
428 "risc pc", in cx88_sram_channel_dump()
435 u32 risc; in cx88_sram_channel_dump() local
438 dprintk0("%s - dma channel status dump\n", ch->name); in cx88_sram_channel_dump()
440 dprintk0(" cmds: %-12s: 0x%08x\n", in cx88_sram_channel_dump()
441 name[i], cx_read(ch->cmds_start + 4 * i)); in cx88_sram_channel_dump()
443 risc = cx_read(ch->cmds_start + 4 * (i + 11)); in cx88_sram_channel_dump()
444 pr_cont(" risc%d: ", i); in cx88_sram_channel_dump()
445 if (--n) in cx88_sram_channel_dump()
446 pr_cont("0x%08x [ arg #%d ]\n", risc, n); in cx88_sram_channel_dump()
448 n = cx88_risc_decode(risc); in cx88_sram_channel_dump()
451 risc = cx_read(ch->ctrl_start + 4 * i); in cx88_sram_channel_dump()
453 n = cx88_risc_decode(risc); in cx88_sram_channel_dump()
455 risc = cx_read(ch->ctrl_start + 4 * (i + j)); in cx88_sram_channel_dump()
457 i + j, risc, j); in cx88_sram_channel_dump()
461 dprintk0("fifo: 0x%08x -> 0x%x\n", in cx88_sram_channel_dump()
462 ch->fifo_start, ch->fifo_start + ch->fifo_size); in cx88_sram_channel_dump()
463 dprintk0("ctrl: 0x%08x -> 0x%x\n", in cx88_sram_channel_dump()
464 ch->ctrl_start, ch->ctrl_start + 6 * 16); in cx88_sram_channel_dump()
465 dprintk0(" ptr1_reg: 0x%08x\n", cx_read(ch->ptr1_reg)); in cx88_sram_channel_dump()
466 dprintk0(" ptr2_reg: 0x%08x\n", cx_read(ch->ptr2_reg)); in cx88_sram_channel_dump()
467 dprintk0(" cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg)); in cx88_sram_channel_dump()
468 dprintk0(" cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg)); in cx88_sram_channel_dump()
500 /* ------------------------------------------------------------------ */
513 status, core->pci_irqmask); in cx88_core_irq()
523 buf = list_entry(q->active.next, in cx88_wakeup()
525 buf->vb.vb2_buf.timestamp = ktime_get_ns(); in cx88_wakeup()
526 buf->vb.field = core->field; in cx88_wakeup()
527 buf->vb.sequence = q->count++; in cx88_wakeup()
528 list_del(&buf->list); in cx88_wakeup()
529 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); in cx88_wakeup()
535 /* disable RISC controller + IRQs */ in cx88_shutdown()
566 cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int in cx88_reset()
604 cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int in cx88_reset()
606 /* Reset on-board parts */ in cx88_reset()
615 /* ------------------------------------------------------------------ */
641 return 28636360; // 3.57954545 MHz +/- 10 Hz in norm_fsc8()
650 return 35468950; // 4.43361875 MHz +/- 5 Hz in norm_fsc8()
671 unsigned int swidth = norm_swidth(core->tvnorm); in cx88_set_scale()
672 unsigned int sheight = norm_maxh(core->tvnorm); in cx88_set_scale()
678 v4l2_norm_to_name(core->tvnorm)); in cx88_set_scale()
683 value = (width * norm_hdelay(core->tvnorm)) / swidth; in cx88_set_scale()
689 value = (swidth * 4096 / width) - 4096; in cx88_set_scale()
698 // recalc V scale Register (delay is constant) in cx88_set_scale()
699 cx_write(MO_VDELAY_EVEN, norm_vdelay(core->tvnorm)); in cx88_set_scale()
700 cx_write(MO_VDELAY_ODD, norm_vdelay(core->tvnorm)); in cx88_set_scale()
701 dprintk(1, "set_scale: vdelay 0x%04x\n", norm_vdelay(core->tvnorm)); in cx88_set_scale()
703 value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff; in cx88_set_scale()
715 if (core->tvnorm & V4L2_STD_SECAM) { in cx88_set_scale()
719 if (INPUT(core->input).type == CX88_VMUX_SVIDEO) in cx88_set_scale()
724 value |= (1 << 0); // 3-tap interpolation in cx88_set_scale()
726 value |= (1 << 1); // 5-tap interpolation in cx88_set_scale()
757 return -1; in set_pll()
774 return -1; in set_pll()
779 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */ in cx88_start_audio_dma()
784 /* If downstream RISC is enabled, bail out; ALSA is managing DMA */ in cx88_start_audio_dma()
805 /* If downstream RISC is enabled, bail out; ALSA is managing DMA */ in cx88_stop_audio_dma()
817 v4l2_std_id norm = core->tvnorm; in set_tvaudio()
819 if (INPUT(core->input).type != CX88_VMUX_TELEVISION && in set_tvaudio()
820 INPUT(core->input).type != CX88_VMUX_CABLE) in set_tvaudio()
824 core->tvaudio = WW_BG; in set_tvaudio()
827 core->tvaudio = WW_DK; in set_tvaudio()
830 core->tvaudio = WW_I; in set_tvaudio()
833 core->tvaudio = WW_L; in set_tvaudio()
837 core->tvaudio = WW_BG; in set_tvaudio()
840 core->tvaudio = WW_DK; in set_tvaudio()
844 core->tvaudio = WW_BTSC; in set_tvaudio()
847 core->tvaudio = WW_EIAJ; in set_tvaudio()
851 v4l2_norm_to_name(core->tvnorm)); in set_tvaudio()
852 core->tvaudio = WW_NONE; in set_tvaudio()
861 * This should be needed only on cx88-alsa. It seems that some cx88 chips have in set_tvaudio()
878 if (norm == core->tvnorm) in cx88_set_tvnorm()
880 if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || in cx88_set_tvnorm()
881 vb2_is_busy(&core->v4ldev->vb2_vbiq))) in cx88_set_tvnorm()
882 return -EBUSY; in cx88_set_tvnorm()
883 if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) in cx88_set_tvnorm()
884 return -EBUSY; in cx88_set_tvnorm()
885 core->tvnorm = norm; in cx88_set_tvnorm()
925 v4l2_norm_to_name(core->tvnorm), fsc8, adc_clock, vdec_clock, in cx88_set_tvnorm()
938 // FIXME: as-is from DScaler in cx88_set_tvnorm()
999 v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM); in cx88_set_tvnorm()
1006 /* ------------------------------------------------------------------ */
1022 vfd->v4l2_dev = &core->v4l2_dev; in cx88_vdev_init()
1023 vfd->dev_parent = &pci->dev; in cx88_vdev_init()
1024 vfd->release = video_device_release_empty; in cx88_vdev_init()
1025 vfd->lock = &core->lock; in cx88_vdev_init()
1026 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", in cx88_vdev_init()
1027 core->name, type, core->board.name); in cx88_vdev_init()
1037 if (pci->bus->number != core->pci_bus) in cx88_core_get()
1039 if (PCI_SLOT(pci->devfn) != core->pci_slot) in cx88_core_get()
1046 refcount_inc(&core->refcount); in cx88_core_get()
1054 list_add_tail(&core->devlist, &cx88_devlist); in cx88_core_get()
1067 if (!refcount_dec_and_test(&core->refcount)) in cx88_core_put()
1072 if (core->i2c_rc == 0) { in cx88_core_put()
1073 i2c_unregister_device(core->i2c_rtc); in cx88_core_put()
1074 i2c_del_adapter(&core->i2c_adap); in cx88_core_put()
1076 list_del(&core->devlist); in cx88_core_put()
1077 iounmap(core->lmmio); in cx88_core_put()
1078 cx88_devcount--; in cx88_core_put()
1080 v4l2_ctrl_handler_free(&core->video_hdl); in cx88_core_put()
1081 v4l2_ctrl_handler_free(&core->audio_hdl); in cx88_core_put()
1082 v4l2_device_unregister(&core->v4l2_dev); in cx88_core_put()