From: Kevin Hilman <khilman@baylibre.com> Date: 2016-12-07 18:30:28
Prepare the groundwork for adding DT support for davinci VPIF drivers.
This series does some fixups/cleanups and then adds the DT binding and
DT compatible string matching for DT probing.
The controversial part from previous versions around async subdev
parsing, and specifically hard-coding the input/output routing of
subdevs, has been left out of this series. That part can be done as a
follow-on step after agreement has been reached on the path forward.
With this version, platforms can still use the VPIF capture/display
drivers, but must provide platform_data for the subdevs and subdev
routing.
Tested video capture to memory on da850-lcdk board using composite
input.
Changes since v5:
- locking fix: updated comment around lock variable
- binding doc: added example for
- added reviewed-by tags from Laurent (thanks!)
Changes since v4:
- dropped controversial async subdev parsing support. That can be
done as a follow-up step after the discussions have finalized on the
right approach.
- DT binding Acked by DT maintainer (Rob H.)
- reworked locking fix (suggested by Laurent)
Changes since v3:
- move to a single VPIF node, DT binding updated accordingly
- misc fixes/updates based on reviews from Sakari
Changes since v2:
- DT binding doc: fix example to use correct compatible
Changes since v1:
- more specific compatible strings, based on SoC: ti,da850-vpif*
- fix locking bug when unlocking over subdev s_stream
Kevin Hilman (5):
[media] davinci: VPIF: fix module loading, init errors
[media] davinci: vpif_capture: remove hard-coded I2C adapter id
[media] davinci: vpif_capture: fix start/stop streaming locking
[media] dt-bindings: add TI VPIF documentation
[media] davinci: VPIF: add basic support for DT init
.../devicetree/bindings/media/ti,da850-vpif.txt | 83 ++++++++++++++++++++++
drivers/media/platform/davinci/vpif.c | 14 +++-
drivers/media/platform/davinci/vpif_capture.c | 26 +++++--
drivers/media/platform/davinci/vpif_capture.h | 2 +-
drivers/media/platform/davinci/vpif_display.c | 6 ++
include/media/davinci/vpif_types.h | 1 +
6 files changed, 125 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/ti,da850-vpif.txt
--
2.9.3
From: Kevin Hilman <khilman@baylibre.com> Date: 2016-12-07 18:30:29
Fix problems with automatic module loading by adding MODULE_ALIAS. Also
fix various load-time errors cause by incorrect or not present
platform_data.
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
drivers/media/platform/davinci/vpif.c | 5 ++++-
drivers/media/platform/davinci/vpif_capture.c | 15 ++++++++++++++-
drivers/media/platform/davinci/vpif_display.c | 6 ++++++
3 files changed, 24 insertions(+), 2 deletions(-)
@@ -647,6 +648,10 @@ static int vpif_input_to_subdev(vpif_dbg(2,debug,"vpif_input_to_subdev\n");+if(!chan_cfg)+return-1;+if(input_index>=chan_cfg->input_count)+return-1;subdev_name=chan_cfg->inputs[input_index].subdev_name;if(subdev_name==NULL)return-1;
@@ -654,7 +659,7 @@ static int vpif_input_to_subdev(/* loop through the sub device list to get the sub device info */for(i=0;i<vpif_cfg->subdev_count;i++){subdev_info=&vpif_cfg->subdev_info[i];-if(!strcmp(subdev_info->name,subdev_name))+if(subdev_info&&!strcmp(subdev_info->name,subdev_name))returni;}return-1;
@@ -685,6 +690,9 @@ static int vpif_set_input(if(sd_index>=0){sd=vpif_obj.sd[sd_index];subdev_info=&vpif_cfg->subdev_info[sd_index];+}else{+/* no subdevice, no input to setup */+return0;}/* first setup input path from sub device to vpif */
@@ -42,6 +42,7 @@ module_param(debug, int, 0644);MODULE_PARM_DESC(debug,"Debug level 0-1");#define VPIF_DRIVER_NAME "vpif_display"+MODULE_ALIAS("platform:"VPIF_DRIVER_NAME);/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */staticintycmux_mode;
@@ -82,6 +82,7 @@ struct vpif_capture_config {structvpif_capture_chan_configchan_config[VPIF_CAPTURE_MAX_CHANNELS];structvpif_subdev_info*subdev_info;intsubdev_count;+inti2c_adapter_id;constchar*card_name;structv4l2_async_subdev**asd;/* Flat array, arranged in groups */int*asd_sizes;/* 0-terminated array of asd group sizes */
From: Kevin Hilman <khilman@baylibre.com> Date: 2016-12-07 18:30:31
Video capture subdevs may be over I2C and may sleep during xfer, so we
cannot do IRQ-disabled locking when calling the subdev.
The IRQ-disabled locking is meant to protect the DMA queue list
throughout the rest of the driver, so update the locking in
[start|stop]_streaming to protect just this list, and update the irqlock
comment to reflect what it actually protects.
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
drivers/media/platform/davinci/vpif_capture.c | 6 +++---
drivers/media/platform/davinci/vpif_capture.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
@@ -179,8 +179,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)unsignedlongaddr,flags;intret;-spin_lock_irqsave(&common->irqlock,flags);-/* Initialize field_id */ch->field_id=0;
@@ -211,6 +209,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)vpif_config_addr(ch,ret);/* Get the next frame from the buffer queue */+spin_lock_irqsave(&common->irqlock,flags);common->cur_frm=common->next_frm=list_entry(common->dma_queue.next,structvpif_cap_buffer,list);/* Remove buffer from the buffer queue */
@@ -244,6 +243,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)return0;err:+spin_lock_irqsave(&common->irqlock,flags);list_for_each_entry_safe(buf,tmp,&common->dma_queue,list){list_del(&buf->list);vb2_buffer_done(&buf->vb.vb2_buf,VB2_BUF_STATE_QUEUED);
@@ -287,7 +287,6 @@ static void vpif_stop_streaming(struct vb2_queue *vq)vpif_dbg(1,debug,"stream off failed in subdev\n");/* release all active buffers */-spin_lock_irqsave(&common->irqlock,flags);if(common->cur_frm==common->next_frm){vb2_buffer_done(&common->cur_frm->vb.vb2_buf,VB2_BUF_STATE_ERROR);
@@ -67,7 +67,7 @@ struct common_obj {structvb2_queuebuffer_queue;/* Queue of filled frames */structlist_headdma_queue;-/* Used in video-buf */+/* Protects the dma_queue field */spinlock_tirqlock;/* lock used to access this structure */structmutexlock;
@@ -0,0 +1,83 @@+Texas Instruments VPIF+----------------------++The TI Video Port InterFace (VPIF) is the primary component for video+capture and display on the DA850/AM18x family of TI DaVinci/Sitara+SoCs.++TI Document reference: SPRUH82C, Chapter 35+http://www.ti.com/lit/pdf/spruh82++Required properties:+- compatible: must be "ti,da850-vpif"+- reg: physical base address and length of the registers set for the device;+- interrupts: should contain IRQ line for the VPIF++Video Capture:++VPIF has a 16-bit parallel bus input, supporting 2 8-bit channels or a+single 16-bit channel. It should contain at least one port child node+with child 'endpoint' node. Please refer to the bindings defined in+Documentation/devicetree/bindings/media/video-interfaces.txt.++Example using 2 8-bit input channels, one of which is connected to an+I2C-connected TVP5147 decoder:++ vpif: vpif at 217000 {+ compatible = "ti,da850-vpif";+ reg = <0x217000 0x1000>;+ interrupts = <92>;++ port {+ vpif_ch0: endpoint at 0 {+ reg = <0>;+ bus-width = <8>;+ remote-endpoint = <&composite>;+ };++ vpif_ch1: endpoint at 1 {+ reg = <1>;+ bus-width = <8>;+ data-shift = <8>;+ };+ };+ };++[ ... ]++&i2c0 {++ tvp5147 at 5d {+ compatible = "ti,tvp5147";+ reg = <0x5d>;+ status = "okay";++ port {+ composite: endpoint {+ hsync-active = <1>;+ vsync-active = <1>;+ pclk-sample = <0>;++ /* VPIF channel 0 (lower 8-bits) */+ remote-endpoint = <&vpif_ch0>;+ bus-width = <8>;+ };+ };+ };+};+++Alternatively, an example when the bus is configured as a single+16-bit input (e.g. for raw-capture mode):++ vpif: vpif at 217000 {+ compatible = "ti,da850-vpif";+ reg = <0x217000 0x1000>;+ interrupts = <92>;++ port {+ vpif_ch0: endpoint {+ bus-width = <16>;+ };+ };+ };
From: Javier Martinez Canillas <javier@dowhile0.org> Date: 2016-12-07 20:03:15
Hello Kevin,
On Wed, Dec 7, 2016 at 3:30 PM, Kevin Hilman [off-list ref] wrote:
Prepare the groundwork for adding DT support for davinci VPIF drivers.
This series does some fixups/cleanups and then adds the DT binding and
DT compatible string matching for DT probing.
The controversial part from previous versions around async subdev
parsing, and specifically hard-coding the input/output routing of
subdevs, has been left out of this series. That part can be done as a
follow-on step after agreement has been reached on the path forward.
I had a similar need for another board (OMAP3 IGEPv2), that has a
TVP5151 video decoder (that also supports 2 composite or 1 s-video
signal) attached to the OMAP3 ISP.
I posted some RFC patches [0] to define the input signals in the DT,
and AFAICT Laurent and Hans were not against the approach but just had
some comments on the DT binding.
Basically they wanted the ports to be directly in the tvp5150 node
instead of under a connectors sub-node [1] and to just be called just
a (input / output) port instead of a connector [2].
Unfortunately I was busy with other tasks so I couldn't res-pin the
patches, but I think you could have something similar in the DT
binding for your case and it shouldn't be hard to parse the ports /
endpoints in the driver to get that information from DT and setup the
input and output pins.
With this version, platforms can still use the VPIF capture/display
drivers, but must provide platform_data for the subdevs and subdev
routing.
I guess DT backward compatibility isn't a big issue on this platform,
since support for the platform is quite recently and after all someone
who wants to use the vpif with current DT will need platform data and
pdata-quirks anyways. So I agree with you that the input / output
signals lookup from DT could be done as a follow-up.
[0]: https://lkml.org/lkml/2016/4/12/983
[1]: https://lkml.org/lkml/2016/4/27/678
[2]: https://lkml.org/lkml/2016/11/11/346
Best regards,
Javier
@@ -1486,7 +1486,10 @@ static __init int vpif_probe(struct platform_device *pdev)}if(!vpif_obj.config->asd_sizes){-i2c_adap=i2c_get_adapter(1);+inti2c_id=vpif_obj.config->i2c_adapter_id;
Is there a particular reason to use a temporary variable just once? I'd use
the i2c_adapter_field directly instead. Up to you.
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
quoted hunk
+
+ i2c_adap = i2c_get_adapter(i2c_id);
+ WARN_ON(!i2c_adap);
for (i = 0; i < subdev_count; i++) {
subdevdata = &vpif_obj.config->subdev_info[i];
vpif_obj.sd[i] =
@@ -82,6 +82,7 @@ struct vpif_capture_config {structvpif_capture_chan_configchan_config[VPIF_CAPTURE_MAX_CHANNELS];structvpif_subdev_info*subdev_info;intsubdev_count;+inti2c_adapter_id;constchar*card_name;structv4l2_async_subdev**asd;/* Flat array, arranged in groups */int*asd_sizes;/* 0-terminated array of asd group sizes */
--
Sakari Ailus
e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
From: Hans Verkuil <hidden> Date: 2016-12-16 09:44:24
On 07/12/16 19:30, Kevin Hilman wrote:
quoted hunk
Fix problems with automatic module loading by adding MODULE_ALIAS. Also
fix various load-time errors cause by incorrect or not present
platform_data.
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
drivers/media/platform/davinci/vpif.c | 5 ++++-
drivers/media/platform/davinci/vpif_capture.c | 15 ++++++++++++++-
drivers/media/platform/davinci/vpif_display.c | 6 ++++++
3 files changed, 24 insertions(+), 2 deletions(-)
@@ -647,6 +648,10 @@ static int vpif_input_to_subdev(vpif_dbg(2,debug,"vpif_input_to_subdev\n");+if(!chan_cfg)+return-1;+if(input_index>=chan_cfg->input_count)+return-1;subdev_name=chan_cfg->inputs[input_index].subdev_name;if(subdev_name==NULL)return-1;
@@ -654,7 +659,7 @@ static int vpif_input_to_subdev(/* loop through the sub device list to get the sub device info */for(i=0;i<vpif_cfg->subdev_count;i++){subdev_info=&vpif_cfg->subdev_info[i];-if(!strcmp(subdev_info->name,subdev_name))+if(subdev_info&&!strcmp(subdev_info->name,subdev_name))
Why this change? subdev_info can never be NULL.
Regards,
Hans
quoted hunk
return i;
}
return -1;
@@ -685,6 +690,9 @@ static int vpif_set_input( if (sd_index >= 0) { sd = vpif_obj.sd[sd_index]; subdev_info = &vpif_cfg->subdev_info[sd_index];+ } else {+ /* no subdevice, no input to setup */+ return 0; } /* first setup input path from sub device to vpif */
@@ -1435,6 +1443,11 @@ static __init int vpif_probe(struct platform_device *pdev) int res_idx = 0; int i, err;+ if (!pdev->dev.platform_data) {+ dev_warn(&pdev->dev, "Missing platform data. Giving up.\n");+ return -EINVAL;+ }+ vpif_dev = &pdev->dev; err = initialize_vpif();
@@ -42,6 +42,7 @@ module_param(debug, int, 0644);MODULE_PARM_DESC(debug,"Debug level 0-1");#define VPIF_DRIVER_NAME "vpif_display"+MODULE_ALIAS("platform:"VPIF_DRIVER_NAME);/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */staticintycmux_mode;
From: Hans Verkuil <hidden> Date: 2016-12-16 09:47:12
On 07/12/16 19:30, Kevin Hilman wrote:
Prepare the groundwork for adding DT support for davinci VPIF drivers.
This series does some fixups/cleanups and then adds the DT binding and
DT compatible string matching for DT probing.
The controversial part from previous versions around async subdev
parsing, and specifically hard-coding the input/output routing of
subdevs, has been left out of this series. That part can be done as a
follow-on step after agreement has been reached on the path forward.
With this version, platforms can still use the VPIF capture/display
drivers, but must provide platform_data for the subdevs and subdev
routing.
Tested video capture to memory on da850-lcdk board using composite
input.
Other than the comment for the first patch this series looks good.
So once that's addressed I'll queue it up for 4.11.
Regards,
Hans
Changes since v5:
- locking fix: updated comment around lock variable
- binding doc: added example for
- added reviewed-by tags from Laurent (thanks!)
Changes since v4:
- dropped controversial async subdev parsing support. That can be
done as a follow-up step after the discussions have finalized on the
right approach.
- DT binding Acked by DT maintainer (Rob H.)
- reworked locking fix (suggested by Laurent)
Changes since v3:
- move to a single VPIF node, DT binding updated accordingly
- misc fixes/updates based on reviews from Sakari
Changes since v2:
- DT binding doc: fix example to use correct compatible
Changes since v1:
- more specific compatible strings, based on SoC: ti,da850-vpif*
- fix locking bug when unlocking over subdev s_stream
Kevin Hilman (5):
[media] davinci: VPIF: fix module loading, init errors
[media] davinci: vpif_capture: remove hard-coded I2C adapter id
[media] davinci: vpif_capture: fix start/stop streaming locking
[media] dt-bindings: add TI VPIF documentation
[media] davinci: VPIF: add basic support for DT init
.../devicetree/bindings/media/ti,da850-vpif.txt | 83 ++++++++++++++++++++++
drivers/media/platform/davinci/vpif.c | 14 +++-
drivers/media/platform/davinci/vpif_capture.c | 26 +++++--
drivers/media/platform/davinci/vpif_capture.h | 2 +-
drivers/media/platform/davinci/vpif_display.c | 6 ++
include/media/davinci/vpif_types.h | 1 +
6 files changed, 125 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/ti,da850-vpif.txt
From: Kevin Hilman <khilman@baylibre.com> Date: 2016-12-17 00:47:57
Fix problems with automatic module loading by adding MODULE_ALIAS. Also
fix various load-time errors cause by incorrect or not present
platform_data.
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
Minor tweaks since v6
- added ack from Sakari
- droped an extraneous change for NULL subdev_info
drivers/media/platform/davinci/vpif.c | 5 ++++-
drivers/media/platform/davinci/vpif_capture.c | 13 +++++++++++++
drivers/media/platform/davinci/vpif_display.c | 6 ++++++
3 files changed, 23 insertions(+), 1 deletion(-)
@@ -647,6 +648,10 @@ static int vpif_input_to_subdev(vpif_dbg(2,debug,"vpif_input_to_subdev\n");+if(!chan_cfg)+return-1;+if(input_index>=chan_cfg->input_count)+return-1;subdev_name=chan_cfg->inputs[input_index].subdev_name;if(subdev_name==NULL)return-1;
@@ -685,6 +690,9 @@ static int vpif_set_input(if(sd_index>=0){sd=vpif_obj.sd[sd_index];subdev_info=&vpif_cfg->subdev_info[sd_index];+}else{+/* no subdevice, no input to setup */+return0;}/* first setup input path from sub device to vpif */
@@ -42,6 +42,7 @@ module_param(debug, int, 0644);MODULE_PARM_DESC(debug,"Debug level 0-1");#define VPIF_DRIVER_NAME "vpif_display"+MODULE_ALIAS("platform:"VPIF_DRIVER_NAME);/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */staticintycmux_mode;
From: Sekhar Nori <hidden> Date: 2017-01-03 09:04:32
Hi Hans,
On Friday 16 December 2016 03:17 PM, Hans Verkuil wrote:
On 07/12/16 19:30, Kevin Hilman wrote:
quoted
Prepare the groundwork for adding DT support for davinci VPIF drivers.
This series does some fixups/cleanups and then adds the DT binding and
DT compatible string matching for DT probing.
The controversial part from previous versions around async subdev
parsing, and specifically hard-coding the input/output routing of
subdevs, has been left out of this series. That part can be done as a
follow-on step after agreement has been reached on the path forward.
With this version, platforms can still use the VPIF capture/display
drivers, but must provide platform_data for the subdevs and subdev
routing.
Tested video capture to memory on da850-lcdk board using composite
input.
Other than the comment for the first patch this series looks good.
So once that's addressed I'll queue it up for 4.11.
Can you provide an immutable commit (as it will reach v4.11) with with
this series applied? I have some platform changes to queue for v4.11
that depend on the driver updates.
Thanks,
Sekhar
Hi Sekhar,
On Tuesday 03 Jan 2017 14:33:00 Sekhar Nori wrote:
On Friday 16 December 2016 03:17 PM, Hans Verkuil wrote:
quoted
On 07/12/16 19:30, Kevin Hilman wrote:
quoted
Prepare the groundwork for adding DT support for davinci VPIF drivers.
This series does some fixups/cleanups and then adds the DT binding and
DT compatible string matching for DT probing.
The controversial part from previous versions around async subdev
parsing, and specifically hard-coding the input/output routing of
subdevs, has been left out of this series. That part can be done as a
follow-on step after agreement has been reached on the path forward.
With this version, platforms can still use the VPIF capture/display
drivers, but must provide platform_data for the subdevs and subdev
routing.
Tested video capture to memory on da850-lcdk board using composite
input.
Other than the comment for the first patch this series looks good.
So once that's addressed I'll queue it up for 4.11.
Can you provide an immutable commit (as it will reach v4.11) with with
this series applied? I have some platform changes to queue for v4.11
that depend on the driver updates.
I don't think that's possible, given that Mauro rewrites all patches when
handling pull requests to prepend [media] to the subject line and to add his
SoB. Only Mauro can thus provide a stable branch, Hans can't.
--
Regards,
Laurent Pinchart
From: Sekhar Nori <hidden> Date: 2017-01-04 11:35:08
+ Mauro
On Tuesday 03 January 2017 02:42 PM, Laurent Pinchart wrote:
Hi Sekhar,
On Tuesday 03 Jan 2017 14:33:00 Sekhar Nori wrote:
quoted
On Friday 16 December 2016 03:17 PM, Hans Verkuil wrote:
quoted
On 07/12/16 19:30, Kevin Hilman wrote:
quoted
Prepare the groundwork for adding DT support for davinci VPIF drivers.
This series does some fixups/cleanups and then adds the DT binding and
DT compatible string matching for DT probing.
The controversial part from previous versions around async subdev
parsing, and specifically hard-coding the input/output routing of
subdevs, has been left out of this series. That part can be done as a
follow-on step after agreement has been reached on the path forward.
With this version, platforms can still use the VPIF capture/display
drivers, but must provide platform_data for the subdevs and subdev
routing.
Tested video capture to memory on da850-lcdk board using composite
input.
Other than the comment for the first patch this series looks good.
So once that's addressed I'll queue it up for 4.11.
Can you provide an immutable commit (as it will reach v4.11) with with
this series applied? I have some platform changes to queue for v4.11
that depend on the driver updates.
I don't think that's possible, given that Mauro rewrites all patches when
handling pull requests to prepend [media] to the subject line and to add his
SoB. Only Mauro can thus provide a stable branch, Hans can't.
Hi Mauro, once Hans sends you these patches, can you host these patches
on a stable branch, which I can merge into my pull request to ARM-SoC. I
have some platform updates that depend on these driver changes.
Ideally the branch has only these patches over an early v4.10-rc so I
include as little of media stuff as possible in my pull request.
Thanks,
Sekhar