// SPDX-License-Identifier: GPL-2.0-or-later /* * TW5864 driver - core functions * * Copyright (C) 2016 Bluecherry, LLC <[email protected]> */ #include <linux/init.h> #include <linux/list.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/kmod.h> #include <linux/sound.h> #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/dma-mapping.h> #include <linux/pm.h> #include <linux/pci_ids.h> #include <linux/jiffies.h> #include <asm/dma.h> #include <media/v4l2-dev.h> #include "tw5864.h" #include "tw5864-reg.h" MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; /* * BEWARE OF KNOWN ISSUES WITH VIDEO QUALITY * * This driver was developed by Bluecherry LLC by deducing behaviour of * original manufacturer's driver, from both source code and execution traces. * It is known that there are some artifacts on output video with this driver: * - on all known hardware samples: random pixels of wrong color (mostly * white, red or blue) appearing and disappearing on sequences of P-frames; * - on some hardware samples (known with H.264 core version e006:2800): * total madness on P-frames: blocks of wrong luminance; blocks of wrong * colors "creeping" across the picture. * There is a workaround for both issues: avoid P-frames by setting GOP size * to 1. To do that, run this command on device files created by this driver: * * v4l2-ctl --device /dev/videoX --set-ctrl=video_gop_size=1 * * These issues are not decoding errors; all produced H.264 streams are decoded * properly. Streams without P-frames don't have these artifacts so it's not * analog-to-digital conversion issues nor internal memory errors; we conclude * it's internal H.264 encoder issues. * We cannot even check the original driver's behaviour because it has never * worked properly at all in our development environment. So these issues may * be actually related to firmware or hardware. However it may be that there's * just some more register settings missing in the driver which would please * the hardware. * Manufacturer didn't help much on our inquiries, but feel free to disturb * again the support of Intersil (owner of former Techwell). */ /* take first free /dev/videoX indexes by default */ static unsigned int video_nr[] = …; module_param_array(…); MODULE_PARM_DESC(…) …; /* * Please add any new PCI IDs to: https://pci-ids.ucw.cz. This keeps * the PCI ID database up to date. Note that the entries must be * added under vendor 0x1797 (Techwell Inc.) as subsystem IDs. */ static const struct pci_device_id tw5864_pci_tbl[] = …; void tw5864_irqmask_apply(struct tw5864_dev *dev) { … } static void tw5864_interrupts_disable(struct tw5864_dev *dev) { … } static void tw5864_timer_isr(struct tw5864_dev *dev); static void tw5864_h264_isr(struct tw5864_dev *dev); static irqreturn_t tw5864_isr(int irq, void *dev_id) { … } static void tw5864_h264_isr(struct tw5864_dev *dev) { … } static void tw5864_input_deadline_update(struct tw5864_input *input) { … } static void tw5864_timer_isr(struct tw5864_dev *dev) { … } static int tw5864_initdev(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) { … } static void tw5864_finidev(struct pci_dev *pci_dev) { … } static struct pci_driver tw5864_pci_driver = …; module_pci_driver(…) …;