History log of /linux-master/drivers/media/pci/cobalt/cobalt-driver.c
Revision Date Author Comments
# f301fedb 13-Sep-2023 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

media: cobalt: Use FIELD_GET() to extract Link Width

Use FIELD_GET() to extract PCIe Negotiated and Maximum Link Width fields
instead of custom masking and shifting.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>


# 887069f4 22-Aug-2021 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

media: 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.

It has been compile tested.

@@
@@
- 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>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 3d37ef41 23-Apr-2021 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: cobalt: fix race condition in setting HPD

The cobalt_s_bit_sysctrl reads the old register value over PCI,
then changes a bit and sets writes the new value to the register.

This is used among other things for setting the HPD output pin.

But if the HPD is changed for multiple inputs at the same time,
then this causes a race condition where a stale value is read.

Serialize this function with a mutex.

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


# a2e2c1b8 07-Apr-2021 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: cobalt: drop static for sd_fmt

The struct v4l2_subdev_format sd_fmt cannot be static since it can be
written back by the subdev. Just have it on the stack.

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


# 6f4eaea2 23-Mar-2021 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: cobalt: fix initial EDID

The EDID failed with two edid-decode warnings:

Block 1, CTA-861 Extension Block:
Video Data Block: VIC 16 is the preferred timing, overriding the first detailed timings. Is this intended?
Video Capability Data Block: S_PT is equal to S_IT and S_CE, so should be set to 0 instead.

In addition, the first DTD had a wrong vsync value (6 instead of 5).

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


# 25a3d6ba 07-Aug-2019 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: adv7511/cobalt: rename driver name to adv7511-v4l2

Commit b2ce5617dad2 ("media: i2c: fix warning same module names")
renamed the adv7511 module in the media tree to adv7511-v4l2.

This patch does the same rename for the driver name and device id to
keep the naming consistent.

Since the cobalt driver loads this module, it had to be renamed there
as well.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 6732ecb3 17-Jul-2019 Frederick Lawler <fred@fredlawl.com>

media: cobalt: Prefer pcie_capability_read_word()

Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
added accessors for the PCI Express Capability so that drivers didn't
need to be aware of differences between v1 and v2 of the PCI
Express Capability.

Replace pci_read_config_word() and pci_write_config_word() calls with
pcie_capability_read_word() and pcie_capability_write_word().

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


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

media: pci: cobalt: Replace GFP_ATOMIC with GFP_KERNEL in cobalt_probe()

cobalt_probe() is never called in atomic context.
It calls kzalloc() with GFP_ATOMIC, which is not necessary.
GFP_ATOMIC can be replaced with GFP_KERNEL.

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>


# 6884db3c 07-Feb-2018 Hans Verkuil <hansverk@cisco.com>

media: cobalt: add SPDX license info

Replace the old license information with the corresponding SPDX
license.

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


# 201c7996 28-Aug-2017 Hans Verkuil <hverkuil@xs4all.nl>

media: cobalt: do not register subdev nodes

In the distant past the adv7604 driver used private controls. In order
to access them the v4l-subdevX nodes were needed. Later the is_private
tag was removed in the adv7604 driver and the need for v4l-subdevX
device nodes disappeared.

Remove the creation of those device nodes from this driver.

Note: the cobalt card is only used inside Cisco and we never actually
used the v4l-subdevX nodes for anything. So this API change can be done
safely without breaking anything.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# e90ce8aa 05-Sep-2017 Colin Ian King <colin.king@canonical.com>

media: cobalt: remove redundant zero check on retval

The error handling paths all end up with retval being non-zero,
so the check for retval being zero is always false and hence
is redundant. Remove it.

Detected by CoverityScan CID#1309479 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


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

media: cobalt: 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>


# b9150e81 23-Apr-2017 Pan Bian <bianpan2016@163.com>

[media] cobalt: fix unchecked return values

Function pci_find_ext_capability() may return 0, which is an invalid
address. In function cobalt_pcie_status_show(), its return value is used
without validation. This patch adds checks to validate the return
address.

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


# e8e8dd6d 09-Jan-2017 Christoph Hellwig <hch@lst.de>

[media] cobalt: use pci_irq_allocate_vectors()

Simplify the interrupt setup by using the new PCI layer helpers.

Despite using pci_enable_msi_range(), this driver was only requesting a
single MSI vector anyway.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>


# 78ccbf9f 11-Sep-2016 Christoph Hellwig <hch@lst.de>

[media] media/cobalt: use pci_irq_allocate_vectors

Simply the interrupt setup by using the new PCI layer helpers.

Despite using pci_enable_msi_range, this driver was only requesting a
single MSI vector anyway.

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


# 036bbb82 05-Sep-2016 Hans Verkuil <hans.verkuil@cisco.com>

[media] cobalt: update EDID

Update the cobalt EDID, fixing various incorrect values (wrong name,
product code, various video capabilities).

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


# e3513f3f 28-Jun-2016 Hans Verkuil <hans.verkuil@cisco.com>

[media] ezkit/cobalt: drop unused op_656_range setting

The adv7604/adv7842 drivers now handle that register setting themselves
and need no input from platform data anymore.

This was a left-over from the time that the pixelport output format was
decided by the platform data.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Scott Jiang <scott.jiang.linux@gmail.com>
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>


# b5dcee22 09-Nov-2015 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] include/media: split I2C headers from V4L2 core

Currently, include/media is messy, as it contains both the V4L2 core
headers and some driver-specific headers on the same place. That makes
harder to identify what core headers should be documented and what
headers belong to I2C drivers that are included only by bridge/main
drivers that would require the functions provided by them.

Let's move those i2c specific files to its own subdirectory.

The files to move were produced via the following script:
mkdir include/media/i2c
(cd include/media; for i in *.h; do n=`echo $i|sed s/.h$/.c/`; if [ -e ../../drivers/media/i2c/$n ]; then echo $i; git mv $i i2c/; fi; done)
(cd include/media; for i in *.h; do n=`echo $i|sed s/.h$/.c/`; if [ -e ../../drivers/media/*/i2c/$n ]; then echo $i; git mv $i i2c/; fi; done)
for i in include/media/*.h; do n=`basename $i`; (for j in $(git grep -l $n); do dirname $j; done)|sort|uniq|grep -ve '^.$' > list; num=$(wc -l list|cut -d' ' -f1); if [ $num == 1 ]; then if [ "`grep i2c list`" != "" ]; then git mv $i include/media/i2c; fi; fi; done

And the references corrected via this script:
MAIN_DIR="media/"
PREV_DIR="media/"
DIRS="i2c/"

echo "Checking affected files" >&2
for i in $DIRS; do
for j in $(find include/$MAIN_DIR/$i -type f -name '*.h'); do
n=`basename $j`
git grep -l $n
done
done|sort|uniq >files && (
echo "Handling files..." >&2;
echo "for i in \$(cat files|grep -v Documentation); do cat \$i | \\";
(
cd include/$MAIN_DIR;
for j in $DIRS; do
for i in $(ls $j); do
echo "perl -ne 's,(include [\\\"\\<])$PREV_DIR($i)([\\\"\\>]),\1$MAIN_DIR$j\2\3,; print \$_' |\\";
done;
done;
echo "cat > a && mv a \$i; done";
);
echo "Handling documentation..." >&2;
echo "for i in MAINTAINERS \$(cat files); do cat \$i | \\";
(
cd include/$MAIN_DIR;
for j in $DIRS; do
for i in $(ls $j); do
echo " perl -ne 's,include/$PREV_DIR($i)\b,include/$MAIN_DIR$j\1,; print \$_' |\\";
done;
done;
echo "cat > a && mv a \$i; done"
);
) >script && . ./script

Merged Sakari Ailus patch that moves smiapp.h to include/media/i2c.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>


# 55b858b4 17-Jul-2015 Hans Verkuil <hverkuil@xs4all.nl>

[media] cobalt: allow fewer than 8 PCIe lanes

Currently the cobalt driver refuses to load if fewer than 8 PCIe lanes
are assigned. This patch changes this and just issues a warning. The
only time it will refuse to load is if the number of assigned lanes is less
than what the PCIe host is capable of since this suggests that the card
isn't seated correctly in the slot.

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


# b4dbad8f 07-Jun-2015 Hans Verkuil <hans.verkuil@cisco.com>

[media] adv7511: log the currently set infoframes

The adv7511 sets up InfoFrames that are used when transmitting video.
Log the contents of those InfoFrames so it is possible to see exactly what
the transmitter is sending.

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


# 4a561c4b 22-May-2015 Hans Verkuil <hans.verkuil@cisco.com>

[media] cobalt: fix sparse warnings

drivers/media/pci/cobalt/cobalt-flash.c:39:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:54:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:63:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:82:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:107:19: warning: incorrect type in assignment (different address spaces)

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


# 86bad00a 21-May-2015 Hans Verkuil <hans.verkuil@cisco.com>

[media] cobalt: fix irqs used for the adv7511 transmitter

The interrupt bit assignments use for the adv7511 were off by one.
This means that the current scheme (bit << (4 * stream_index)) can
no longer be used.

Fix this by precalculating and storing the correct masks in the
cobalt_stream struct.

This wasn't noticed before because the adv7511 interrupts are very
rare. But for CEC support these interrupts are essential, so this made
me realize that it wasn't working correctly.

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


# 85756a06 12-May-2015 Hans Verkuil <hans.verkuil@cisco.com>

[media] cobalt: add new driver

The cobalt device is a PCIe card with 4 HDMI inputs (adv7604) and a
connector that can be used to hook up an adv7511 transmitter or an
adv7842 receiver daughterboard.

This device is used within Cisco but is sadly not available outside
of Cisco. Nevertheless it is a very interesting driver that can serve
as an example of how to support HDMI hardware and how to use the popular
adv devices.

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