History log of /linux-master/drivers/media/pci/cx23885/cx23885-core.c
Revision Date Author Comments
# b134b30f 30-Jul-2023 Mariusz Bialonczyk <manio@skyboo.net>

media: cx23885: debug cosmetics

This commit is fixing the module in a way that trailing spaces
at the end of the line in the debug/dmesg are gone.

Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>


# 47e8b73b 02-Mar-2023 harperchen <harperchen1110@gmail.com>

media: cx23885: Fix a null-ptr-deref bug in buffer_prepare() and buffer_finish()

When the driver calls cx23885_risc_buffer() to prepare the buffer, the
function call dma_alloc_coherent may fail, resulting in a empty buffer
risc->cpu. Later when we free the buffer or access the buffer, null ptr
deref is triggered.

This bug is similar to the following one:
https://git.linuxtv.org/media_stage.git/commit/?id=2b064d91440b33fba5b452f2d1b31f13ae911d71.

We believe the bug can be also dynamically triggered from user side.
Similarly, we fix this by checking the return value of cx23885_risc_buffer()
and the value of risc->cpu before buffer free.

Signed-off-by: harperchen <harperchen1110@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# a7985e3c 18-Aug-2022 Daniel Lee Kruse <daniel.lee.kruse@proton.me>

media: cx23885: reset DMA on AMD Renior/Cezanne IOMMU due to RiSC engine stall

MythTv is unable to scan channels with APUs with the Renior IOMMU
that is also contained in the Cezanne line of APUs. This issue
was discovered on the 5.15 version the kernel. This patch adds
the IOMMU PCI ID to the broken_dev_id array.

This patch was developed with 5.19 of the media_tree repo.

[hverkuil: cleaned up the commit log a bit]

Signed-off-by: Daniel Lee Kruse <daniel.lee.kruse@proton.me>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# e8123311 10-Apr-2022 Zheyu Ma <zheyuma97@gmail.com>

media: pci: cx23885: Fix the error handling in cx23885_initdev()

When the driver fails to call the dma_set_mask(), the driver will get
the following splat:

[ 55.853884] BUG: KASAN: use-after-free in __process_removed_driver+0x3c/0x240
[ 55.854486] Read of size 8 at addr ffff88810de60408 by task modprobe/590
[ 55.856822] Call Trace:
[ 55.860327] __process_removed_driver+0x3c/0x240
[ 55.861347] bus_for_each_dev+0x102/0x160
[ 55.861681] i2c_del_driver+0x2f/0x50

This is because the driver has initialized the i2c related resources
in cx23885_dev_setup() but not released them in error handling, fix this
bug by modifying the error path that jumps after failing to call the
dma_set_mask().

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 7a77379f 28-Mar-2021 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

media: cx23885: switch from 'pci_' to 'dma_' API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.

When memory is allocated in 'cx23885_risc_buffer()' GFP_KERNEL can be used
because this function is only called from a vb2_ops buf_prepare function.
The call chain is:
cx23885_video_qops.buf_prepare (cx23885-video.c)
--> buffer_prepare (cx23885-video.c)
--> cx23885_risc_buffer

When memory is allocated in 'cx23885_risc_databuffer()' GFP_KERNEL can be
used because this function is only called from a function that already uses
GFP_KERNEL or from a vb2_ops buf_prepare
function.
The call chains are:
snd_cx23885_hw_params (cx23885-alsa.c) --> use GFP_KERNEL
--> cx23885_risc_databuffer

cx23885_qops.buffer_prepare (cx23885-417.c)
or
dvb_qops.buffer_prepare (cx23885-dvb.c)
--> cx23885_buf_prepare
--> cx23885_risc_databuffer

When memory is allocated in 'cx23885_risc_vbibuffer()' GFP_KERNEL can be
used because this function is only called from a vb2_ops buf_prepare
function.
The call chains are:
cx23885_vbi_qops.buffer_prepare (cx23885-vbi.c)
--> cx23885_risc_vbibuffer

@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL

@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE

@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE

@@
@@
- PCI_DMA_NONE
+ DMA_NONE

@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 5f864cfb 25-Jan-2021 Brad Love <brad@nextdimension.cc>

media: cx23885: add more quirks for reset DMA on some AMD IOMMU

The folowing AMD IOMMU are affected by the RiSC engine stall, requiring a
reset to maintain continual operation. After being added to the
broken_dev_id list the systems are functional long term.

0x1481 is the PCI ID for the IOMMU found on Starship/Matisse

0x1419 is the PCI ID for the IOMMU found on 15h (Models 10h-1fh) family

0x5a23 is the PCI ID for the IOMMU found on RD890S/RD990

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# dbf0b3a7 29-Sep-2020 Daniel Lee Kruse <daniel.lee.kruse@protonmail.com>

media: cx23885: add more quirks for reset DMA on some AMD IOMMU

On AMD Family 15h (Models 30h-3fh), I/O Memory Management Unit
RiSC engine sometimes stalls, requiring a reset.

As result, MythTV and w-scan won't scan channels on the AMD Kaveri
APU with the Hauppauge QuadHD TV tuner card.

For the solution I added the Input/Output Memory Management Unit's PCI
Identity of 0x1423 to the broken_dev_id[] array, which is used by
a quirks logic meant to fix similar problems with other AMD
chipsets.

Signed-off-by: Daniel Lee Kruse <daniel.lee.kruse@protonmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 9bb83e8f 13-Oct-2020 Thomas Gleixner <tglx@linutronix.de>

media: Bulk remove BUG_ON(in_interrupt())

None of these BUG_ON()'s is justified. BUG_ON() should only be used when
there is really no way to survive.

If at all these could be replaced by lockdep_assert_preemption_enabled() to
cover all invalid caller context and not just those covered by
in_interrupt().

But all functions which are invoked from those places contain already debug
mechanisms to catch wrong context, so having these extra checks is not
having any advantage.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# d6f65828 17-Jul-2020 Vaibhav Gupta <vaibhavgupta40@gmail.com>

media: cx23885: use generic power management

The .suspend() and .resume() callbacks are not defined for this driver.
Still, their power management structure follows the legacy framework. To
bring it under the generic framework, simply remove the binding of
callbacks from struct "pci_driver".

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# c942fddf 27-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157

Based on 3 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version [author] [kishon] [vijay] [abraham]
[i] [kishon]@[ti] [com] this program is distributed in the hope that
it will be useful but without any warranty without even the implied
warranty of merchantability or fitness for a particular purpose see
the gnu general public license for more details

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version [author] [graeme] [gregory]
[gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
[kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
[hk] [hemahk]@[ti] [com] this program is distributed in the hope
that it will be useful but without any warranty without even the
implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1105 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 16790554 18-Feb-2019 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

media: pci: fix several typos

Use codespell to fix lots of typos over frontends.

Manually verified to avoid false-positives.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 4bd46aa0 18-Dec-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: only reset DMA on problematic CPUs

It is reported that commit 95f408bbc4e4 ("media: cx23885: Ryzen DMA
related RiSC engine stall fixes") caused regresssions with other CPUs.

Ensure that the quirk will be applied only for the CPUs that
are known to cause problems.

A module option is added for explicit control of the behaviour.

Fixes: 95f408bbc4e4 ("media: cx23885: Ryzen DMA related RiSC engine stall fixes")

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 71be8dee 26-Jul-2018 Jia-Ju Bai <baijiaju1990@gmail.com>

media: pci: cx23885: Replace mdelay() with msleep() in cx23885_reset()

cx23885_reset() is never called in atomic context.
It calls mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep().

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# ff9d1c01 08-May-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Add some missing register documentation

Document what these two register calls are doing.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# f72ff638 08-May-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Expand registers in dma tsport reg dump

Include some additional useful registers in the output.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 95f408bb 08-May-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Ryzen DMA related RiSC engine stall fixes

This bug affects all of Hauppauge QuadHD boards when used on all Ryzen
platforms and some XEON platforms. On these platforms it is possible to
error out the RiSC engine and cause it to stall, whereafter the only
way to reset the board to a working state is to reboot.

This is the fatal condition with current driver:

[ 255.663598] cx23885: cx23885[0]: mpeg risc op code error
[ 255.663607] cx23885: cx23885[0]: TS1 B - dma channel status dump
[ 255.663612] cx23885: cx23885[0]: cmds: init risc lo : 0xffe54000
[ 255.663615] cx23885: cx23885[0]: cmds: init risc hi : 0x00000000
[ 255.663619] cx23885: cx23885[0]: cmds: cdt base : 0x00010870
[ 255.663622] cx23885: cx23885[0]: cmds: cdt size : 0x0000000a
[ 255.663625] cx23885: cx23885[0]: cmds: iq base : 0x00010630
[ 255.663629] cx23885: cx23885[0]: cmds: iq size : 0x00000010
[ 255.663632] cx23885: cx23885[0]: cmds: risc pc lo : 0xffe54018
[ 255.663636] cx23885: cx23885[0]: cmds: risc pc hi : 0x00000000
[ 255.663639] cx23885: cx23885[0]: cmds: iq wr ptr : 0x00004192
[ 255.663642] cx23885: cx23885[0]: cmds: iq rd ptr : 0x0000418c
[ 255.663645] cx23885: cx23885[0]: cmds: cdt current : 0x00010898
[ 255.663649] cx23885: cx23885[0]: cmds: pci target lo : 0xf85ca340
[ 255.663652] cx23885: cx23885[0]: cmds: pci target hi : 0x00000000
[ 255.663655] cx23885: cx23885[0]: cmds: line / byte : 0x000c0000
[ 255.663659] cx23885: cx23885[0]: risc0:
[ 255.663661] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663666] cx23885: cx23885[0]: risc1:
[ 255.663667] 0xf85ca050 [ INVALID sol 22 20 19 18 resync 13 count=80 ]
[ 255.663674] cx23885: cx23885[0]: risc2:
[ 255.663674] 0x00000000 [ INVALID count=0 ]
[ 255.663678] cx23885: cx23885[0]: risc3:
[ 255.663679] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663684] cx23885: cx23885[0]: (0x00010630) iq 0:
[ 255.663685] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663690] cx23885: cx23885[0]: iq 1: 0xf85ca630 [ arg #1 ]
[ 255.663693] cx23885: cx23885[0]: iq 2: 0x00000000 [ arg #2 ]
[ 255.663696] cx23885: cx23885[0]: (0x0001063c) iq 3:
[ 255.663697] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663702] cx23885: cx23885[0]: iq 4: 0xf85ca920 [ arg #1 ]
[ 255.663705] cx23885: cx23885[0]: iq 5: 0x00000000 [ arg #2 ]
[ 255.663709] cx23885: cx23885[0]: (0x00010648) iq 6:
[ 255.663709] 0xf85ca340 [ INVALID sol 22 20 19 18 resync 13 count=832 ]
[ 255.663716] cx23885: cx23885[0]: (0x0001064c) iq 7:
[ 255.663717] 0x00000000 [ INVALID count=0 ]
[ 255.663721] cx23885: cx23885[0]: (0x00010650) iq 8:
[ 255.663721] 0x00000000 [ INVALID count=0 ]
[ 255.663725] cx23885: cx23885[0]: (0x00010654) iq 9:
[ 255.663726] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663731] cx23885: cx23885[0]: iq a: 0xf85c9780 [ arg #1 ]
[ 255.663734] cx23885: cx23885[0]: iq b: 0x00000000 [ arg #2 ]
[ 255.663737] cx23885: cx23885[0]: (0x00010660) iq c:
[ 255.663738] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663743] cx23885: cx23885[0]: iq d: 0xf85c9a70 [ arg #1 ]
[ 255.663746] cx23885: cx23885[0]: iq e: 0x00000000 [ arg #2 ]
[ 255.663749] cx23885: cx23885[0]: (0x0001066c) iq f:
[ 255.663750] 0x1c0002f0 [ write sol eol count=752 ]
[ 255.663755] cx23885: cx23885[0]: iq 10: 0xf4fa2920 [ arg #1 ]
[ 255.663758] cx23885: cx23885[0]: iq 11: 0x00000000 [ arg #2 ]
[ 255.663759] cx23885: cx23885[0]: fifo: 0x00005000 -> 0x6000
[ 255.663760] cx23885: cx23885[0]: ctrl: 0x00010630 -> 0x10690
[ 255.663764] cx23885: cx23885[0]: ptr1_reg: 0x00005980
[ 255.663767] cx23885: cx23885[0]: ptr2_reg: 0x000108a8
[ 255.663770] cx23885: cx23885[0]: cnt1_reg: 0x0000000b
[ 255.663773] cx23885: cx23885[0]: cnt2_reg: 0x00000003

Included is checks of the TC_REQ and TC_REQ_SET registers during states
of board initialization, reset, DMA start, and DMA stop. If both registers
are set, this indicates a stall in the RiSC engine, at which point the
bridge error is cleared.

A small delay is introduced in stop_dma as well, to allow transfers in
progress to finish.

After application all models work on Ryzen, occasionally yielding:

cx23885_clear_bridge_error: dma in progress detected 0x00000001 0x00000001, clearing

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
[hansverk@cisco.com: fix compiler warning of unused 'reg' variable]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 3b8315f3 08-May-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Use PCI and TS masks in irq functions

Currently mask is read for pci_status/ts1_status/ts2_status, but
otherwise ignored. The masks are now used to determine whether
action is warranted.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 9a7dc2b0 08-May-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Handle additional bufs on interrupt

On Ryzen systems interrupts are occasionally missed:

cx23885: cx23885_wakeup: [ffff99b384b83c00/28] wakeup reg=5406 buf=5405
cx23885: cx23885_wakeup: [ffff99b40bf79400/31] wakeup reg=9537 buf=9536

This patch loops up to five times on wakeup, marking any buffers
found done.

Since the count register is u16, but the vb2 counter is u32, some modulo
arithmetic is used to accommodate wraparound and ensure current active
buffer is the buffer expected.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 3aab15af 21-Feb-2018 Hans Verkuil <hverkuil@xs4all.nl>

media: add tuner standby op, use where needed

The v4l2_subdev core s_power op was used for two different things: power on/off
sensors or video decoders/encoders and to put a tuner in standby (and only the
tuner!). There is no 'tuner wakeup' op, that's done automatically when the tuner
is accessed.

The danger with calling (s_power, 0) to put a tuner into standby is that it is
usually broadcast for all subdevs. So a video receiver subdev that supports
s_power will also be powered off, and since there is no corresponding (s_power, 1)
they will never be powered on again.

In addition, this is specifically meant for tuners only since they draw the most
current.

This patch adds a new tuner op called 'standby' and replaces all calls to
(core, s_power, 0) by (tuner, standby). This prevents confusion between the two
uses of s_power. Note that there is no overlap: bridge drivers either just want
to put the tuner into standby, or they deal with powering on/off sensors. Never
both.

This also makes it easier to replace s_power for the remaining bridge drivers
with some PM code later.

Whether we want something cleaner for tuners in the future is a separate topic.
There is a lot of legacy code surrounding tuners, and I am very hesitant about
making changes there.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 779c79d4 06-Mar-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Override 888 ImpactVCBe crystal frequency

Hauppauge produced a revision of ImpactVCBe using an 888,
with a 25MHz crystal, instead of using the default third
overtone 50Mhz crystal. This overrides that frequency so
that the cx25840 is properly configured. Without the proper
crystal setup the cx25840 cannot load the firmware or
decode video.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 5da1a682 06-Mar-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: change 887/888 default to 888

Proper cx2388x chip type is detected in cx25840 probe, the clock
rate is untouched however in probe. The cx25840 only checks for
non default clock values for 888 and provides custom settings for
25MHz 888. This change ensures that cx23888 chips with default 50MHz
crystals will not get configured as if they have 25MHz crystals. A
cx23887 board will continue to be configured for 25MHz crystal as
there is no custom clock support included for it.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# c00ba2c1 05-Jan-2018 Brad Love <brad@nextdimension.cc>

media: cx23885: Add support for new Hauppauge QuadHD (885)

Add new QuadHD digital only PCIe boards to driver list.
Differentiate them from 888 digital/analog QuadHD models.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 0fcefb39 01-Aug-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

media: cx23885: constify pci_device_id

pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by <linux/pci.h> work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# e39682b5 13-Nov-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] cx23885: convert it to use pr_foo() macros

Instead of calling printk() directly, use pr_foo()
macros, as suggested at the Kernel's coding style.

Please notice that a conversion to dev_foo() is not trivial,
as several parts on this driver uses pr_cont().

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 09f8be26 14-Oct-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] cx23885: use KERN_CONT where needed

Some continuation messages are not using KERN_CONT.

Since commit 563873318d32 ("Merge branch 'printk-cleanups'"),
this won't work as expected anymore. So, let's add KERN_CONT
to those lines.

While here, add missing log level annotations.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 07ab29e1 18-Oct-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] cx23885: don't break long lines

Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.

As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.

So, join those continuation lines.

The patch was generated via the script below, and manually
adjusted if needed.

</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;

$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");

print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 2bc46b3a 14-Feb-2016 Hans Verkuil <hans.verkuil@cisco.com>

[media] media/pci: convert drivers to use the new vb2_queue dev field

Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Federico Vaga <federico.vaga@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# d6dd645e 03-Nov-2015 Junghak Sung <jh1009.sung@samsung.com>

[media] media: videobuf2: Move timestamp to vb2_buffer

Move timestamp from struct vb2_v4l2_buffer to struct vb2_buffer
for common use, and change its type to u64 in order to handling
y2038 problem. This patch also includes all device drivers' changes related to
this restructuring.

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 6c43a217 30-Nov-2015 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: add support for ViewCast 260e and 460e

Add support for these two new cards.

Based upon Devin's initial patch made for an older kernel which I
cleaned up and rebased. Thanks to Kernel Labs for that work.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 1a47de6e 20-Nov-2015 Christoph Hellwig <hch@lst.de>

various: fix pci_set_dma_mask return value checking

pci_set_dma_mask returns a negative errno value, not a bool like
pci_dma_supported. This of course was just a giant test for attention :)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Jongman Heo <jongman.heo@samsung.com>
Tested-by: Jongman Heo <jongman.heo@samsung.com> [pcnet32]
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 4571e4a2 10-Nov-2015 Christoph Hellwig <hch@lst.de>

cx23885: use pci_set_dma_mask insted of pci_dma_supported

This ensures the dma mask that is supported by the driver is recorded
in the device structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 2d700715 22-Sep-2015 Junghak Sung <jh1009.sung@samsung.com>

[media] media: videobuf2: Restructure vb2_buffer

Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.

Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}

Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};

v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;

__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# af7f388e 26-Mar-2015 David Howells <dhowells@redhat.com>

[media] cx23885: Always initialise dev->slock spinlock

The slock spinlock in the cx23885_dev struct is only initialised if analogue
video is being used, but is used in other places too, leading to the attached
lockdep complaint.

Move the lock initialisation so that it is done unconditionally.

INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 1 PID: 4413 Comm: scandvb Tainted: G W 4.0.0-rc1-fsdevel+ #25
Hardware name: System manufacturer System Product Name/P5Q PRO TURBO, BIOS 0701 10/08/2012
0000000000000000 ffff880129d779d8 ffffffff8162bbdf 0000000000000006
0000000000000000 ffff880129d77aa8 ffffffff810780e3 0000000000000001
0000000000000046 0000000000000004 ffffffff81c3f180 0000000000000000
Call Trace:
[<ffffffff8162bbdf>] dump_stack+0x4c/0x65
[<ffffffff810780e3>] __lock_acquire+0x7b5/0x1a0e
[<ffffffff810799ee>] lock_acquire+0x97/0x10c
[<ffffffffa006494e>] ? cx23885_buf_queue+0x69/0x142 [cx23885]
[<ffffffff8102e9bc>] ? amd_set_subcaches+0x19b/0x19b
[<ffffffff816313b4>] _raw_spin_lock_irqsave+0x36/0x4a
[<ffffffffa006494e>] ? cx23885_buf_queue+0x69/0x142 [cx23885]
[<ffffffffa006494e>] cx23885_buf_queue+0x69/0x142 [cx23885]
[<ffffffffa00662cb>] buffer_queue+0x17/0x19 [cx23885]
[<ffffffffa00382d5>] __enqueue_in_driver+0x6a/0x6f [videobuf2_core]
[<ffffffffa0038ead>] vb2_start_streaming+0x37/0x129 [videobuf2_core]
[<ffffffffa003a6c0>] vb2_internal_streamon+0xc5/0x105 [videobuf2_core]
[<ffffffffa003b889>] __vb2_init_fileio+0x224/0x286 [videobuf2_core]
[<ffffffffa003bcc0>] ? vb2_thread_start+0x7b/0x15f [videobuf2_core]
[<ffffffffa0050182>] ? vb2_dvb_start_feed+0x86/0x86 [videobuf2_dvb]
[<ffffffffa003bd06>] vb2_thread_start+0xc1/0x15f [videobuf2_core]
[<ffffffff8150d393>] ? dmx_section_feed_start_filtering+0x2f/0x14f
[<ffffffffa0050157>] vb2_dvb_start_feed+0x5b/0x86 [videobuf2_dvb]
[<ffffffff8150d461>] dmx_section_feed_start_filtering+0xfd/0x14f
[<ffffffff8150afc7>] dvb_dmxdev_filter_start+0x23f/0x315
[<ffffffff8150b6ad>] dvb_demux_do_ioctl+0x1fb/0x556
[<ffffffff81509e94>] dvb_usercopy+0xb4/0x11c
[<ffffffff8150b4b2>] ? dvb_dmxdev_ts_callback+0xd0/0xd0
[<ffffffff8150a11a>] dvb_demux_ioctl+0x10/0x14
[<ffffffff81144ac4>] do_vfs_ioctl+0x3c1/0x474
[<ffffffff8126f181>] ? file_has_perm+0x5b/0x7f
[<ffffffff810bf6ca>] ? __audit_syscall_entry+0xbc/0xde
[<ffffffff81144bcc>] SyS_ioctl+0x55/0x7a
[<ffffffff81631d52>] system_call_fastpath+0x12/0x17

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 8d4d9329 19-Jan-2015 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: fix free interrupt bug

First free the interrupt, then disable the PCI device. The other way
around will lead to this warning:

Jan 19 11:42:02 telek kernel: [ 1440.161234] WARNING: CPU: 0 PID: 2191 at kernel/irq/manage.c:1311 __free_irq+0x97/0x1f0()
Jan 19 11:42:02 telek kernel: [ 1440.161236] Trying to free already-free IRQ 0
Jan 19 11:42:02 telek kernel: [ 1440.161237] Modules linked in: tda8290 tda10048 cx25840 cx23885(-) altera_ci tda18271 altera_stapl videobuf2_dvb tveeprom cx2341x videobuf2_dma_sg dvb_core rc_core videobuf2_memops videobuf2_core v4l2_common videodev media nouveau x86_pkg_temp_thermal cfbfillrect cfbimgblt cfbcopyarea ttm drm_kms_helper processor button isci
Jan 19 11:42:02 telek kernel: [ 1440.161266] CPU: 0 PID: 2191 Comm: rmmod Tainted: G W 3.19.0-rc1-telek #345
Jan 19 11:42:02 telek kernel: [ 1440.161268] Hardware name: ASUSTeK COMPUTER INC. Z9PE-D8 WS/Z9PE-D8 WS, BIOS 5404 02/10/2014
Jan 19 11:42:02 telek kernel: [ 1440.161270] ffffffff81bf1fce ffff8808958b7cc8 ffffffff8194a97f 0000000000000000
Jan 19 11:42:02 telek kernel: [ 1440.161274] ffff8808958b7d18 ffff8808958b7d08 ffffffff810c56b0 0000000000000286
Jan 19 11:42:02 telek kernel: [ 1440.161279] 0000000000000000 0000000000000000 ffff88089f808890 ffff88089f808800
Jan 19 11:42:02 telek kernel: [ 1440.161284] Call Trace:
Jan 19 11:42:02 telek kernel: [ 1440.161290] [<ffffffff8194a97f>] dump_stack+0x4f/0x7b
Jan 19 11:42:02 telek kernel: [ 1440.161295] [<ffffffff810c56b0>] warn_slowpath_common+0x80/0xc0
Jan 19 11:42:02 telek kernel: [ 1440.161299] [<ffffffff810c5731>] warn_slowpath_fmt+0x41/0x50
Jan 19 11:42:02 telek kernel: [ 1440.161303] [<ffffffff81955d36>] ? _raw_spin_lock_irqsave+0x56/0x70
Jan 19 11:42:02 telek kernel: [ 1440.161307] [<ffffffff81114849>] ? __free_irq+0x49/0x1f0
Jan 19 11:42:02 telek kernel: [ 1440.161311] [<ffffffff81114897>] __free_irq+0x97/0x1f0
Jan 19 11:42:02 telek kernel: [ 1440.161316] [<ffffffff81114a88>] free_irq+0x48/0xd0
Jan 19 11:42:02 telek kernel: [ 1440.161323] [<ffffffffa00e6deb>] cx23885_finidev+0x4b/0x90 [cx23885]
Jan 19 11:42:02 telek kernel: [ 1440.161329] [<ffffffff814529fa>] pci_device_remove+0x3a/0xc0
Jan 19 11:42:02 telek kernel: [ 1440.161334] [<ffffffff8153b4ea>] __device_release_driver+0x7a/0xf0
Jan 19 11:42:02 telek kernel: [ 1440.161338] [<ffffffff8153bc98>] driver_detach+0xc8/0xd0
Jan 19 11:42:02 telek kernel: [ 1440.161341] [<ffffffff8153b1de>] bus_remove_driver+0x4e/0xb0
Jan 19 11:42:02 telek kernel: [ 1440.161345] [<ffffffff8153c2eb>] driver_unregister+0x2b/0x60
Jan 19 11:42:02 telek kernel: [ 1440.161349] [<ffffffff814525c5>] pci_unregister_driver+0x25/0x70
Jan 19 11:42:02 telek kernel: [ 1440.161355] [<ffffffffa00f6ddc>] cx23885_fini+0x10/0x12 [cx23885]
Jan 19 11:42:02 telek kernel: [ 1440.161360] [<ffffffff81139a98>] SyS_delete_module+0x1a8/0x1f0
Jan 19 11:42:02 telek kernel: [ 1440.161364] [<ffffffff819561a9>] system_call_fastpath+0x12/0x17
Jan 19 11:42:02 telek kernel: [ 1440.161367] ---[ end trace a9c07cb5f3357020 ]---

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# d790b7ed 24-Nov-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] vb2-dma-sg: move dma_(un)map_sg here

This moves dma_(un)map_sg to the get_userptr/put_userptr and alloc/put
memops of videobuf2-dma-sg.c and adds dma_sync_sg_for_device/cpu to the
prepare/finish memops.

Now that vb2-dma-sg will sync the buffers for you in the prepare/finish
memops we can drop that from the drivers that use dma-sg.

For the solo6x10 driver that was a bit more involved because it needs to
copy JPEG or MPEG headers to the buffer before returning it to userspace,
and that cannot be done in the old place since the buffer there is still
setup for DMA access, not for CPU access. However, the buf_finish
op is the ideal place to do this. By the time buf_finish is called
the buffer is available for CPU access, so copying to the buffer is fine.

[mchehab@osg.samsung.com: Fix a compilation breakage:
drivers/media/v4l2-core/videobuf2-dma-sg.c:150:19: error: 'struct vb2_dma_sg_buf' has no member named 'dma_sgt']

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 0c3a14c1 18-Nov-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] vb2-dma-sg: add allocation context to dma-sg

Require that dma-sg also uses an allocation context. This is in preparation
for adding prepare/finish memops to sync the memory between DMA and CPU.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 7675fe99 21-Nov-2014 Hans Verkuil <hverkuil@xs4all.nl>

[media] cx23885: use sg = sg_next(sg) instead of sg++

The cx23885 driver still used sg++ instead of sg = sg_next(sg). This worked with
vb1 since that filled in the sglist manually, page-by-page, but it fails with vb2
which uses core scatterlist code that can combine contiguous scatterlist entries
into one larger entry.

This bug led to the following crash as reported by Mariusz:

[20712.990258] BUG: Bad page state in process vb2-cx23885[0] pfn:2ca34
[20712.990265] page:ffffea00009c3b60 count:-1 mapcount:0 mapping: (null) index:0x0
[20712.990266] flags: 0x4000000000000000()
[20712.990268] page dumped because: nonzero _count
[20712.990269] Modules linked in: tun binfmt_misc nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_filter ip6_tables xt_mark xt_REDIRECT xt_limit xt_conntrack xt_nat xt_tcpudp iptable_mangle iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_filter ip_tables x_tables sit ip_tunnel nvidia(PO) stb6100 stv090x cx88_dvb videobuf_dvb cx88_vp3054_i2c tuner kvm_amd kvm cx8802 k10temp cx8800 cx88xx btcx_risc videobuf_dma_sg videobuf_core usb_storage ds2490 usbhid ftdi_sio cx23885 tveeprom cx2341x videobuf2_dvb videobuf2_core videobuf2_dma_sg videobuf2_memops asus_atk0110 snd_emu10k1 snd_hwdep snd_util_mem snd_ac97_codec ac97_bus snd_rawmidi snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd w1_therm wire ipv6
[20712.990301] CPU: 2 PID: 26942 Comm: vb2-cx23885[0] Tainted: P B W O 3.18.0-rc5-00001-gb3652d1 #2
[20712.990303] Hardware name: System manufacturer System Product Name/M4A785TD-V EVO, BIOS 2105 07/23/2010
[20712.990305] ffffffff81765734 ffff880137683a78 ffffffff815b6b32 0000000000000006
[20712.990307] ffffea00009c3b60 ffff880137683aa8 ffffffff8108ec27 ffffffff81765712
[20712.990309] ffffffff8189c840 0000000000000246 ffffea00009c3b60 ffff880137683b78
[20712.990312] Call Trace:
[20712.990317] [<ffffffff815b6b32>] dump_stack+0x46/0x58
[20712.990321] [<ffffffff8108ec27>] bad_page+0xe9/0x107
[20712.990323] [<ffffffff810912ca>] get_page_from_freelist+0x3b2/0x505
[20712.990326] [<ffffffff8109150a>] __alloc_pages_nodemask+0xed/0x65f
[20712.990330] [<ffffffff81047a52>] ? ttwu_do_activate.constprop.78+0x57/0x5c
[20712.990332] [<ffffffff81049ff3>] ? try_to_wake_up+0x21b/0x22d
[20712.990336] [<ffffffff810070f4>] dma_generic_alloc_coherent+0x6e/0xf5
[20712.990339] [<ffffffff810261a9>] gart_alloc_coherent+0x105/0x114
[20712.990341] [<ffffffff81025963>] ? flush_gart+0x39/0x3d
[20712.990343] [<ffffffff810260a4>] ? gart_map_sg+0x3a0/0x3a0
[20712.990349] [<ffffffffa0141a1e>] cx23885_risc_databuffer+0xa7/0x133 [cx23885]
[20712.990354] [<ffffffffa0142764>] cx23885_buf_prepare+0x121/0x134 [cx23885]
[20712.990359] [<ffffffffa0144210>] buffer_prepare+0x14/0x16 [cx23885]
[20712.990363] [<ffffffffa011f101>] __buf_prepare+0x190/0x279 [videobuf2_core]
[20712.990366] [<ffffffffa011d906>] ? vb2_queue_or_prepare_buf+0xb8/0xc0 [videobuf2_core]
[20712.990369] [<ffffffffa011f34b>] vb2_internal_qbuf+0x51/0x1e5 [videobuf2_core]
[20712.990372] [<ffffffffa0120537>] vb2_thread+0x199/0x1f6 [videobuf2_core]
[20712.990376] [<ffffffffa012039e>] ? vb2_fop_write+0xdf/0xdf [videobuf2_core]
[20712.990379] [<ffffffff81043e61>] kthread+0xdf/0xe7
[20712.990381] [<ffffffff81043d82>] ? kthread_create_on_node+0x16d/0x16d
[20712.990384] [<ffffffff815bd46c>] ret_from_fork+0x7c/0xb0
[20712.990386] [<ffffffff81043d82>] ? kthread_create_on_node+0x16d/0x16d

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Mariusz Bialonczyk <manio@skyboo.net>
Tested-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 420b2176 20-Sep-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: fix VBI support

Tested VBI support and discovered that the wrong offset was used.
After this change it is now working. Verified with CC/XDS for NTSC
and WSS/Teletext on PAL.

It also reported the wrong start lines for the second field. That's
now fixed as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 4d63a25c 10-Aug-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: remove btcx-risc dependency

It's just as easy to do it in the driver. This dependency only uses a
fraction of the btcx-risc module and doing it directly in the driver
adds only a few lines. The btcx-risc module is really meant for the
bttv driver, not for other drivers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 453afdd9 14-Aug-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: convert to vb2

As usual, this patch is very large due to the fact that half a vb2 conversion
isn't possible. And since this affects 417, alsa, core, dvb, vbi and video the
changes are all over.

What made this more difficult was the peculiar way the risc program was setup.
The driver allowed for running out of buffers in which case the DMA would stop
and restart when the next buffer was queued. There was also a complicated
timeout system for when buffers weren't filled. This was replaced by a much
simpler scheme where there is always one buffer around and the DMA will just
cycle that buffer until a new buffer is queued. In that case the previous
buffer will be chained to the new buffer. An interrupt is generated at the
start of the new buffer telling the driver that the previous buffer can be
passed on to userspace.

Much simpler and more robust. The old code seems to be copied from the
cx88 driver. But it didn't fit the vb2 ops very well and replacing it with
the new scheme made the code easier to understand. Not to mention that this
patch removes 600 lines of code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 03105397 09-Aug-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: remove FSF address as per checkpatch

These addresses are usually out-of-date and the top-level license will
always have the right address. So drop it from these sources.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# da59a4de 23-Apr-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] cx23885: convert to the control framework

This is part 1, converting the uncompressed video/vbi nodes to use
the control framework.

The next patch converts the compressed video node as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 3e018fe4 12-Oct-2013 Michael Opdenacker <michael.opdenacker@free-electrons.com>

[media] misc drivers: remove deprecated IRQF_DISABLED

This patch proposes to remove the use of the IRQF_DISABLED flag
It's a NOOP since 2.6.35 and it will be removed one day.

Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# c21412f5 10-Jul-2013 Luis Alves <ljalvs@gmail.com>

[media] Fixed misleading error when handling IR interrupts

Hi,
Handling the AV Core/IR interrupts schedules its workqueue but
the schedule_work function returns false if @work was already on the
kernel-global workqueue and true otherwise.
Printing an error message if @work wasn't in the queue is wrong.
Regards,
Luis

Signed-off-by: Luis Alves <ljalvs@gmail.com>
Acked-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 4c62e976 21-Dec-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Drivers: media: remove __dev* attributes.

CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
markings need to be removed.

This change removes the use of __devinit, __devexit_p, __devinitdata,
__devinitconst, and __devexit from these drivers.

Based on patches originally written by Bill Pemberton, but redone by me
in order to handle some of the coding style issues better, by hand.

Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8e6057b5 15-Sep-2012 Sakari Ailus <sakari.ailus@linux.intel.com>

[media] v4l: Convert drivers to use monotonic timestamps

Convert drivers using wall clock time (CLOCK_REALTIME) to timestamp from the
monotonic timer (CLOCK_MONOTONIC).

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# ada73eee 27-Oct-2012 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] cx23885: get rid of warning: no previous prototype

drivers/media/pci/cx23885/altera-ci.c:266:5: warning: no previous prototype for 'altera_ci_op_cam' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:301:5: warning: no previous prototype for 'altera_ci_read_attribute_mem' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:307:5: warning: no previous prototype for 'altera_ci_write_attribute_mem' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:313:5: warning: no previous prototype for 'altera_ci_read_cam_ctl' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:319:5: warning: no previous prototype for 'altera_ci_write_cam_ctl' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:325:5: warning: no previous prototype for 'altera_ci_slot_reset' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:368:5: warning: no previous prototype for 'altera_ci_slot_shutdown' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:374:5: warning: no previous prototype for 'altera_ci_slot_ts_ctl' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:451:5: warning: no previous prototype for 'altera_poll_ci_slot_status' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:462:6: warning: no previous prototype for 'altera_hw_filt_release' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:584:5: warning: no previous prototype for 'altera_pid_feed_control' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:606:5: warning: no previous prototype for 'altera_ci_start_feed' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:613:5: warning: no previous prototype for 'altera_ci_stop_feed' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:620:5: warning: no previous prototype for 'altera_ci_start_feed_1' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:625:5: warning: no previous prototype for 'altera_ci_stop_feed_1' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:630:5: warning: no previous prototype for 'altera_ci_start_feed_2' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:635:5: warning: no previous prototype for 'altera_ci_stop_feed_2' [-Wmissing-prototypes]
drivers/media/pci/cx23885/altera-ci.c:640:5: warning: no previous prototype for 'altera_hw_filt_init' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:123:5: warning: no previous prototype for 'netup_write_i2c' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:150:5: warning: no previous prototype for 'netup_ci_get_mem' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:169:5: warning: no previous prototype for 'netup_ci_op_cam' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:239:5: warning: no previous prototype for 'netup_ci_read_attribute_mem' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:245:5: warning: no previous prototype for 'netup_ci_write_attribute_mem' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:251:5: warning: no previous prototype for 'netup_ci_read_cam_ctl' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:257:5: warning: no previous prototype for 'netup_ci_write_cam_ctl' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:263:5: warning: no previous prototype for 'netup_ci_slot_reset' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:292:5: warning: no previous prototype for 'netup_ci_slot_shutdown' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:298:5: warning: no previous prototype for 'netup_ci_set_irq' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:319:5: warning: no previous prototype for 'netup_ci_slot_ts_ctl' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:375:5: warning: no previous prototype for 'netup_ci_slot_status' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:402:5: warning: no previous prototype for 'netup_poll_ci_slot_status' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:415:5: warning: no previous prototype for 'netup_ci_init' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:520:6: warning: no previous prototype for 'netup_ci_exit' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cimax2.c:90:5: warning: no previous prototype for 'netup_read_i2c' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-av.c:26:6: warning: no previous prototype for 'cx23885_av_work_handler' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-cards.c:1430:5: warning: no previous prototype for 'netup_jtag_io' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-core.c:306:6: warning: no previous prototype for 'cx23885_irq_add' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-dvb.c:662:5: warning: no previous prototype for 'netup_altera_fpga_rw' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-f300.c:150:5: warning: no previous prototype for 'f300_set_voltage' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-input.c:249:5: warning: no previous prototype for 'cx23885_input_init' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-input.c:353:6: warning: no previous prototype for 'cx23885_input_fini' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-input.c:76:6: warning: no previous prototype for 'cx23885_input_rx_work_handler' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ioctl.c:134:5: warning: no previous prototype for 'cx23885_g_register' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ioctl.c:185:5: warning: no previous prototype for 'cx23885_s_register' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ioctl.c:27:5: warning: no previous prototype for 'cx23885_g_chip_ident' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ir.c:101:6: warning: no previous prototype for 'cx23885_ir_tx_v4l2_dev_notify' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ir.c:37:6: warning: no previous prototype for 'cx23885_ir_rx_work_handler' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ir.c:60:6: warning: no previous prototype for 'cx23885_ir_tx_work_handler' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23885-ir.c:76:6: warning: no previous prototype for 'cx23885_ir_rx_v4l2_dev_notify' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23888-ir.c:1203:5: warning: no previous prototype for 'cx23888_ir_probe' [-Wmissing-prototypes]
drivers/media/pci/cx23885/cx23888-ir.c:1253:5: warning: no previous prototype for 'cx23888_ir_remove' [-Wmissing-prototypes]
drivers/media/pci/cx23885/netup-init.c:109:6: warning: no previous prototype for 'netup_initialize' [-Wmissing-prototypes]

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 30cfbee3 08-Oct-2012 Wei Yongjun <yongjun_wei@trendmicro.com.cn>

[media] cx23885: use list_move_tail instead of list_del/list_add_tail

Using list_move_tail() instead of list_del() + list_add_tail().
dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# b285192a 13-Aug-2012 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] rename most media/video pci drivers to media/pci

Rename all PCI drivers with their own directory under
drivers/media/video into drivers/media/pci and update the
building system.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>