Skip to content

Commit

Permalink
Merge tag 'media/v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/mchehab/linux-media

Pull more media updates from Mauro Carvalho Chehab:

 - a set of atomisp patches. They remove several abstraction layers, and
   fixes clang and gcc warnings (that were hidden via some macros that
   were disabling 4 or 5 types of warnings there). There are also some
   important fixes and sensor auto-detection on newer BIOSes via ACPI
   _DCM tables.

 - some fixes

* tag 'media/v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (95 commits)
  media: rkvdec: Fix H264 scaling list order
  media: v4l2-ctrls: Unset correct HEVC loop filter flag
  media: videobuf2-dma-contig: fix bad kfree in vb2_dma_contig_clear_max_seg_size
  media: v4l2-subdev.rst: correct information about v4l2 events
  media: s5p-mfc: Properly handle dma_parms for the allocated devices
  media: medium: cec: Make MEDIA_CEC_SUPPORT default to n if !MEDIA_SUPPORT
  media: cedrus: Implement runtime PM
  media: cedrus: Program output format during each run
  media: atomisp: improve ACPI/DMI detection logs
  media: Revert "media: atomisp: add Asus Transform T101HA ACPI vars"
  media: Revert "media: atomisp: Add some ACPI detection info"
  media: atomisp: improve sensor detection code to use _DSM table
  media: atomisp: get rid of an iomem abstraction layer
  media: atomisp: get rid of a string_support.h abstraction layer
  media: atomisp: use strscpy() instead of less secure variants
  media: atomisp: set DFS to MAX if sensor doesn't report fps
  media: atomisp: use different dfs failed messages
  media: atomisp: change the detection of ISP2401 at runtime
  media: atomisp: use macros from intel-family.h
  media: atomisp: don't set hpll_freq twice with different values
  ...
  • Loading branch information
torvalds committed Jun 13, 2020
2 parents d74b15d + 2630e1b commit ac911b3
Show file tree
Hide file tree
Showing 680 changed files with 5,144 additions and 6,804 deletions.
3 changes: 1 addition & 2 deletions Documentation/driver-api/media/v4l2-subdev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ The device node handles a subset of the V4L2 API.
events can also be reported by one (or several) V4L2 device nodes.

Sub-device drivers that want to use events need to set the
``V4L2_SUBDEV_USES_EVENTS`` :c:type:`v4l2_subdev`.flags and initialize
:c:type:`v4l2_subdev`.nevents to events queue depth before registering
``V4L2_SUBDEV_FL_HAS_EVENTS`` :c:type:`v4l2_subdev`.flags before registering
the sub-device. After registration events can be queued as usual on the
:c:type:`v4l2_subdev`.devnode device node.

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/cec/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ config CEC_PIN_ERROR_INJ
menuconfig MEDIA_CEC_SUPPORT
bool
prompt "HDMI CEC drivers"
default y if !MEDIA_SUPPORT_FILTER
default y if MEDIA_SUPPORT && !MEDIA_SUPPORT_FILTER
help
Enable support for HDMI CEC (Consumer Electronics Control),
which is an optional HDMI feature.
Expand Down
20 changes: 2 additions & 18 deletions drivers/media/common/videobuf2/videobuf2-dma-contig.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,8 @@ EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
int vb2_dma_contig_set_max_seg_size(struct device *dev, unsigned int size)
{
if (!dev->dma_parms) {
dev->dma_parms = kzalloc(sizeof(*dev->dma_parms), GFP_KERNEL);
if (!dev->dma_parms)
return -ENOMEM;
dev_err(dev, "Failed to set max_seg_size: dma_parms is NULL\n");
return -ENODEV;
}
if (dma_get_max_seg_size(dev) < size)
return dma_set_max_seg_size(dev, size);
Expand All @@ -737,21 +736,6 @@ int vb2_dma_contig_set_max_seg_size(struct device *dev, unsigned int size)
}
EXPORT_SYMBOL_GPL(vb2_dma_contig_set_max_seg_size);

/*
* vb2_dma_contig_clear_max_seg_size() - release resources for DMA parameters
* @dev: device for configuring DMA parameters
*
* This function releases resources allocated to configure DMA parameters
* (see vb2_dma_contig_set_max_seg_size() function). It should be called from
* device drivers on driver remove.
*/
void vb2_dma_contig_clear_max_seg_size(struct device *dev)
{
kfree(dev->dma_parms);
dev->dma_parms = NULL;
}
EXPORT_SYMBOL_GPL(vb2_dma_contig_clear_max_seg_size);

MODULE_DESCRIPTION("DMA-contig memory handling routines for videobuf2");
MODULE_AUTHOR("Pawel Osciak <[email protected]>");
MODULE_LICENSE("GPL");
6 changes: 5 additions & 1 deletion drivers/media/platform/s5p-mfc/s5p_mfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,10 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
child->coherent_dma_mask = dev->coherent_dma_mask;
child->dma_mask = dev->dma_mask;
child->release = s5p_mfc_memdev_release;
child->dma_parms = devm_kzalloc(dev, sizeof(*child->dma_parms),
GFP_KERNEL);
if (!child->dma_parms)
goto err;

/*
* The memdevs are not proper OF platform devices, so in order for them
Expand All @@ -1104,7 +1108,7 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
return child;
device_del(child);
}

err:
put_device(child);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/v4l2-core/v4l2-ctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
sizeof(p_hevc_pps->row_height_minus1));

p_hevc_pps->flags &=
~V4L2_HEVC_PPS_FLAG_PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED;
~V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED;
}

if (p_hevc_pps->flags &
Expand Down
2 changes: 2 additions & 0 deletions drivers/staging/media/atomisp/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
menuconfig INTEL_ATOMISP
bool "Enable support to Intel Atom ISP camera drivers"
depends on X86 && EFI && PCI && ACPI
Expand All @@ -11,6 +12,7 @@ menuconfig INTEL_ATOMISP
config VIDEO_ATOMISP
tristate "Intel Atom Image Signal Processor Driver"
depends on VIDEO_V4L2 && INTEL_ATOMISP
depends on PMIC_OPREGION
select IOSF_MBI
select VIDEOBUF_VMALLOC
---help---
Expand Down
20 changes: 1 addition & 19 deletions drivers/staging/media/atomisp/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for camera drivers.
#
Expand Down Expand Up @@ -36,7 +37,6 @@ atomisp-objs += \
pci/sh_css_param_dvs.o \
pci/sh_css_param_shading.o \
pci/sh_css_params.o \
pci/sh_css_pipe.o \
pci/sh_css_properties.o \
pci/sh_css_shading.o \
pci/sh_css_sp.o \
Expand All @@ -53,10 +53,7 @@ atomisp-objs += \
pci/hmm/hmm_dynamic_pool.o \
pci/hmm/hmm.o \
pci/hmm/hmm_reserved_pool.o \
pci/hmm/hmm_vm.o \
pci/hrt/hive_isp_css_mm_hrt.o \
pci/ia_css_device_access.o \
pci/ia_css_memory_access.o \
pci/isp/kernels/aa/aa_2/ia_css_aa2.host.o \
pci/isp/kernels/anr/anr_1.0/ia_css_anr.host.o \
pci/isp/kernels/anr/anr_2/ia_css_anr2.host.o \
Expand Down Expand Up @@ -117,7 +114,6 @@ atomisp-objs += \
pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.o \
pci/isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.o \
pci/isp/kernels/ynr/ynr_2/ia_css_ynr2.host.o \
pci/memory_realloc.o \
pci/mmu/isp_mmu.o \
pci/mmu/sh_mmu_mrfld.o \
pci/runtime/binary/src/binary.o \
Expand Down Expand Up @@ -328,11 +324,6 @@ INCLUDES_cht += \
# -I$(atomisp)/pci/css_2401_system/hrt/ \
# -I$(atomisp)/pci/css_2401_system/hive_isp_css_2401_system_generated/ \

ifeq ($(CONFIG_ION),y)
INCLUDES += -I$(srctree)/drivers/staging/android/ion
endif

DEFINES := -DHRT_HW -DHRT_ISP_CSS_CUSTOM_HOST -DHRT_USE_VIR_ADDRS -D__HOST__
#DEFINES += -DUSE_DYNAMIC_BIN
#DEFINES += -DISP_POWER_GATING
Expand All @@ -352,12 +343,3 @@ DEFINES += -DISP2400 -DSYSTEM_hive_isp_css_2400_system
endif

ccflags-y += $(INCLUDES) $(DEFINES) -fno-common

# HACK! While this driver is in bad shape, don't enable several warnings
# that would be otherwise enabled with W=1
ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
ccflags-y += $(call cc-disable-warning, missing-prototypes)
ccflags-y += $(call cc-disable-warning, missing-declarations)
ccflags-y += $(call cc-disable-warning, suggest-attribute=format)
ccflags-y += $(call cc-disable-warning, unused-const-variable)
ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
154 changes: 106 additions & 48 deletions drivers/staging/media/atomisp/TODO
Original file line number Diff line number Diff line change
@@ -1,71 +1,127 @@
1. A single AtomISP driver needs to be implemented to support both
Baytrail (BYT and Cherrytail (CHT) platforms at the same time.
NOTE:
=====

While the driver probes the hardware and reports itself as a
V4L2 driver, there are still some issues preventing it to
stream (at least it doesn't with the standard V4L2 applications.
Didn't test yet with some custom-made app for this driver).
Solving the related bugs and issues preventing it to work is
needed (items 6 and 7 from the list below).

TODO
====

1. The atomisp doesn't rely at the usual i2c stuff to discover the
sensors. Instead, it calls a function from atomisp_gmin_platform.c.
There are some hacks added there for it to wait for sensors to be
probed (with a timeout of 2 seconds or so).
This should be converted to the usual way, using V4L2 async subdev
framework to wait for cameras to be probed;

2. Use ACPI _DSM table - DONE!

3. Switch the driver to use pm_runtime stuff. Right now, it probes the
existing PMIC code and sensors call it directly.

4. There's a problem at the sensor drivers: when trying to set a video
format, the atomisp main driver calls the sensor drivers with the
sensor turned off. This causes them to fail.

The only exception is the atomisp-ov2880, which has a hack inside it
to turn it on when VIDIOC_S_FMT is called.

The right fix seems to power on the sensor when a video device is
opened (or at the first VIDIOC_ ioctl - except for VIDIOC_QUERYCAP),
powering it down at close() syscall.

Such kind of control would need to be done inside the atomisp driver,
not at the sensors code.

5. There are several issues related to memory management, causing
crashes. The atomisp splits the memory management on three separate
regions:

- dynamic pool;
- reserved pool;
- generic pool

The code implementing it is at:

drivers/staging/media/atomisp/pci/hmm/

It also has a separate code for managing DMA buffers at:

drivers/staging/media/atomisp/pci/mmu/

The code there is really dirty, ugly and probably wrong. I fixed
one bug there already, but the best would be to just trash it and use
something else. Maybe the code from the newer intel driver could
serve as a model:

drivers/staging/media/ipu3/ipu3-mmu.c

But converting it to use something like that is painful and may
cause some breakages.

6. There is some issues at the frame receive logic, causing the
DQBUF ioctls to fail.

7. A single AtomISP driver needs to be implemented to support both
Baytrail (BYT) and Cherrytail (CHT) platforms at the same time.
The current driver is a mechanical and hand combined merge of the
two using several runtime macros, plus some ifdef ISP2401 to select the
CHT version. Yet, there are some ISP-specific headers that change the
driver's behavior during compile time.

2. The file structure needs to get tidied up to resemble a normal Linux
8. The file structure needs to get tidied up to resemble a normal Linux
driver.

3. Lots of the midlayer glue. unused code and abstraction needs removing.
9. Lots of the midlayer glue. unused code and abstraction needs removing.

3. The sensor drivers read MIPI settings from EFI variables or default to the
settings hard-coded in the platform data file for different platforms.
It should be possible to improve it, by adding support for _DSM tables.
10. The AtomISP driver includes some special IOCTLS (ATOMISP_IOC_XXXX_XXXX)
and controls that require some cleanup. Some of those code may have
been removed during the cleanups. They could be needed in order to
properly support 3A algorithms

4. The sensor drivers use PMIC and the regulator framework API. In the ideal
world it would be using ACPI but that's not how the existing devices work.
Such IOCTL interface needs more documentation. The better would
be to use something close to the interface used by the IPU3 IMGU driver.

5. The AtomISP driver includes some special IOCTLS (ATOMISP_IOC_XXXX_XXXX)
and controls that require some cleanup.
11. The ISP code has some dependencies of the exact FW version.
The version defined in pci/sh_css_firmware.c:

6. Correct Coding Style. Please don't send coding style patches for this
driver until the other work is done.
BYT (isp2400): "irci_stable_candrpv_0415_20150521_0458"

7. The ISP code has some dependencies of the exact FW version.
The version defined in pci/sh_css_firmware.c:
BYT:
static const char *isp2400_release_version = STR(irci_stable_candrpv_0415_20150521_0458);
CHT (isp2401): "irci_ecr - master_20150911_0724"

CHT:
static const char *isp2401_release_version = STR(irci_ecr - master_20150911_0724);
Those versions don't seem to be available anymore. On the tests we've
done so far, this version also seems to work for CHT:

Those versions don't seem to be available anymore. On the tests we've
done so far, this version also seems to work for isp2401:
"irci_stable_candrpv_0415_20150521_0458"

irci_stable_candrpv_0415_20150521_0458
Which can be obtainable from Yocto Atom ISP respository.

At some point we may need to round up a few driver versions and see if
there are any specific things that can be done to fold in support for
multiple firmware versions.
but this was not thoroughly tested.

8. Switch to V4L2 async API to set up sensor, lens and flash devices.
Control those devices using V4L2 sub-device API without custom
extensions.
At some point we may need to round up a few driver versions and see if
there are any specific things that can be done to fold in support for
multiple firmware versions.

9. Switch to standard V4L2 sub-device API for sensor and lens. In
particular, the user space API needs to support V4L2 controls as
defined in the V4L2 spec and references to atomisp must be removed from
these drivers.
12. Switch to standard V4L2 sub-device API for sensor and lens. In
particular, the user space API needs to support V4L2 controls as
defined in the V4L2 spec and references to atomisp must be removed from
these drivers.

10. Use LED flash API for flash LED drivers such as LM3554 (which already
13. Use LED flash API for flash LED drivers such as LM3554 (which already
has a LED class driver).

11. Switch from videobuf1 to videobuf2. Videobuf1 is being removed!

12. There are some memory management code that seems to be
forked from Kernel 3.10 inside hmm/ directory. Get rid of it,
making the driver to use a more standard memory management module.
14. Switch from videobuf1 to videobuf2. Videobuf1 is being removed!

13. While the driver probes the hardware and reports itself as a
V4L2 driver, there are still some issues preventing it to
stream (at least it doesn't with the standard V4L2 applications.
Didn't test yet with some custom-made app for this driver).
Solving the related bugs and issues preventing it to work is
needed.
15. Correct Coding Style. Please refrain sending coding style patches
for this driver until the other work is done, as there will be a lot
of code churn until this driver becomes functional again.

Limitations:
Limitations
===========

1. To test the patches, you also need the ISP firmware

Expand All @@ -76,14 +132,16 @@ Limitations:
device but can also be extracted from the upgrade kit if you've managed
to lose them somehow.

2. Without a 3A libary the capture behaviour is not very good. To take a good
picture, you need tune ISP parameters by IOCTL functions or use a 3A libary
2. Without a 3A library the capture behaviour is not very good. To take a good
picture, you need tune ISP parameters by IOCTL functions or use a 3A library
such as libxcam.

3. The driver is intended to drive the PCI exposed versions of the device.
It will not detect those devices enumerated via ACPI as a field of the
i915 GPU driver.

There are some patches adding i915 GPU support floating at the Yocto's
Aero repository (so far, untested upstream).

4. The driver supports only v2 of the IPU/Camera. It will not work with the
versions of the hardware in other SoCs.

3 changes: 2 additions & 1 deletion drivers/staging/media/atomisp/i2c/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
#
# Kconfig for sensor drivers
#
Expand Down Expand Up @@ -57,7 +58,7 @@ config VIDEO_ATOMISP_GC0310
---help---
This is a Video4Linux2 sensor-level driver for the Galaxycore
GC0310 0.3MP sensor.

config VIDEO_ATOMISP_OV2680
tristate "Omnivision OV2680 sensor support"
depends on ACPI
Expand Down
13 changes: 1 addition & 12 deletions drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Support for GalaxyCore GC0310 VGA camera sensor.
*
Expand Down Expand Up @@ -1309,18 +1310,6 @@ static int gc0310_probe(struct i2c_client *client)
int ret;
void *pdata;
unsigned int i;
acpi_handle handle;
struct acpi_device *adev;

handle = ACPI_HANDLE(&client->dev);
if (!handle || acpi_bus_get_device(handle, &adev)) {
dev_err(&client->dev, "Error could not get ACPI device\n");
return -ENODEV;
}
pr_info("%s: ACPI detected it on bus ID=%s, HID=%s\n",
__func__, acpi_device_bid(adev), acpi_device_hid(adev));
// FIXME: may need to release resources allocated by acpi_bus_get_device()


dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
Expand Down
Loading

0 comments on commit ac911b3

Please sign in to comment.