v4l2: device_register_subdev_nodes: allow calling multiple times
PATCH 1/4 v4l2: device_register_subdev_nodes: allow calling multiple times
From: Sebastian Reichel <[email protected]>
If v4l2_device_register_subdev_nodes() is called multiple times, it is better to return early than corrupt memory.
Without this, exposure / gain controls do not work in the camera application on N900.
--- drivers/media/v4l2-core/v4l2-device.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/v4l2-core/v4l2-device.c +3 -0
@@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)if (!(sd->flags &V4L2_SUBDEV_FL_HAS_DEVNODE ))continue ; +if (sd->devnode) +continue ; + vdev =kzalloc (sizeof (*vdev),GFP_KERNEL );if (!vdev) { err = -ENOMEM ;
Signature · 6 lines
2.1.4 -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 2/4 Core changes for CCP2/CSI1 support.
From: Sakari Ailus <[email protected]>
CCP2, or CSI-1, is an older single data lane serial bus. Add core support neccessary for it.
--- include/media/v4l2-mediabus.h | 4 ++++ include/media/v4l2-of.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+)
include/media/v4l2-mediabus.h +4 -0
@@ -69,11 +69,15 @@* @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can * also be used for BT.1120 +* @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface +* @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface */ enum v4l2_mbus_type {V4L2_MBUS_PARALLEL ,V4L2_MBUS_BT656 , +V4L2_MBUS_CSI1 , +V4L2_MBUS_CCP2 ,V4L2_MBUS_CSI2 , };
include/media/v4l2-of.h +17 -0
@@ -53,6 +53,22 @@ struct v4l2_of_bus_parallel { };/** +* struct v4l2_of_bus_csi1 - CSI-1/CCP2 data bus structure +* @clock_inv: polarity of clock/strobe signal +* false - not inverted, true - inverted +* @strobe: false - data/clock, true - data/strobe +* @data_lane: the number of the data lane +* @clock_lane: the number of the clock lane +*/ +struct v4l2_of_bus_mipi_csi1 { +bool clock_inv; +bool strobe; +bool lane_polarity[2 ]; +unsigned char data_lane; +unsigned char clock_lane; +}; + +/** * struct v4l2_of_endpoint - the endpoint data structure * @base: struct of_endpoint containing port, id, and local of_node * @bus_type: bus type
@@ -66,6 +82,7 @@ struct v4l2_of_endpoint {enum v4l2_mbus_type bus_type;union {struct v4l2_of_bus_parallel parallel; +struct v4l2_of_bus_mipi_csi1 mipi_csi1;struct v4l2_of_bus_mipi_csi2 mipi_csi2; } bus;u64 *link_frequencies;
Signature · 6 lines
2.1.4 -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 3/4 smiapp: add CCP2 support
In reply to Pavel MachekAdd support for CCP2 connected SMIA sensors as found on the Nokia N900.
--- drivers/media/i2c/smiapp/smiapp-core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/media/i2c/smiapp/smiapp-core.c +10 -4
@@ -2807,13 +2807,19 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)switch (bus_cfg->bus_type) {case V4L2_MBUS_CSI2 : hwcfg->csi_signalling_mode =SMIAPP_CSI_SIGNALLING_MODE_CSI2 ; + hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes; +break ; +case V4L2_MBUS_CCP2 : + hwcfg->csi_signalling_mode = (bus_cfg->bus.mipi_csi1.strobe) ? +SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE : +SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK ; + hwcfg->lanes =1 ;break ; -/* FIXME: add CCP2 support. */ default : +dev_err (dev,"unknown bus protocol\n" ); goto out_err; } - hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;dev_dbg (dev,"lanes %u\n" , hwcfg->lanes);/* NVM size is not mandatory */
@@ -2827,8 +2833,8 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) goto out_err; } -dev_dbg (dev,"nvm %d, clk %d, csi %d\n" , hwcfg->nvm_size, - hwcfg->ext_clk, hwcfg->csi_signalling_mode); +dev_dbg (dev,"nvm %d, clk %d, mode %d\n" , + hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode);if (!bus_cfg->nr_of_link_frequencies) {dev_warn (dev,"no link frequencies defined\n" );
Signature · 6 lines
2.1.4 -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 4/4 v4l: split lane parsing code
In reply to Pavel MachekFrom: Sakari Ailus <[email protected]>
The function to parse CSI2 bus parameters was called v4l2_of_parse_csi_bus(), rename it as v4l2_of_parse_csi2_bus() in anticipation of CSI1/CCP2 support.
Obtain data bus type from bus-type property. Only try parsing bus specific properties in this case.
Separate lane parsing from CSI-2 bus parameter parsing. The CSI-1 will need these as well, separate them into a different function. have_clk_lane and num_data_lanes arguments may be NULL; the CSI-1 bus will have no use for them.
Add support for parsing of CSI-1 and CCP2 bus related properties documented in video-interfaces.txt.
--- drivers/media/v4l2-core/v4l2-of.c | 138 ++++++++++++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 27 deletions(-)
drivers/media/v4l2-core/v4l2-of.c +111 -27
@@ -20,64 +20,103 @@#include <media/v4l2-of.h> -static int v4l2_of_parse_csi_bus (const struct device_node *node, -struct v4l2_of_endpoint *endpoint) +/* This has to match values in the device tree. */ + +enum v4l2_of_bus_type { +V4L2_OF_BUS_TYPE_GUESS =0 ,/* CSI-2 D-PHY, parallel or Bt.656 */ +V4L2_OF_BUS_TYPE_CSI2_CPHY , +V4L2_OF_BUS_TYPE_CSI1 , +V4L2_OF_BUS_TYPE_CCP2 , +}; + +static int v4l2_of_parse_lanes (const struct device_node *node, +unsigned char *clock_lane, +bool *have_clk_lane, +unsigned char *data_lanes, +bool *lane_polarities, +unsigned short *__num_data_lanes, +unsigned int max_data_lanes) { -struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;struct property *prop; -bool have_clk_lane = false; -unsigned int flags =0 , lanes_used =0 ; +unsigned int lanes_used =0 ; +short num_data_lanes =0 ;u32 v; prop =of_find_property (node,"data-lanes" ,NULL );if (prop) {const __be32 *lane =NULL ; -unsigned int i; -for (i =0 ; i <ARRAY_SIZE (bus->data_lanes); i++) { +for (num_data_lanes =0 ; num_data_lanes < max_data_lanes; + num_data_lanes++) { lane =of_prop_next_u32 (prop, lane, &v);if (!lane)break ; + data_lanes[num_data_lanes] = v;if (lanes_used &BIT (v))pr_warn ("%s: duplicated lane %u in data-lanes\n" , node->full_name, v); lanes_used |=BIT (v); - - bus->data_lanes[i] = v; } - bus->num_data_lanes = i; } +if (__num_data_lanes) + *__num_data_lanes = num_data_lanes; prop =of_find_property (node,"lane-polarities" ,NULL );if (prop) {const __be32 *polarity =NULL ;unsigned int i; -for (i =0 ; i <ARRAY_SIZE (bus->lane_polarities); i++) { +for (i =0 ; i <1 + max_data_lanes; i++) { polarity =of_prop_next_u32 (prop, polarity, &v);if (!polarity)break ; - bus->lane_polarities[i] = v; + lane_polarities[i] = v; } -if (i <1 + bus->num_data_lanes/* clock + data */ ) { +if (i <1 + num_data_lanes/* clock + data */ ) {pr_warn ("%s: too few lane-polarities entries (need %u, got %u)\n" , - node->full_name,1 + bus->num_data_lanes, i); + node->full_name,1 + num_data_lanes, i);return -EINVAL ; } } +if (have_clk_lane) + *have_clk_lane = false; +if (!of_property_read_u32 (node,"clock-lanes" , &v)) { + *clock_lane = v; +if (have_clk_lane) + *have_clk_lane = true; +if (lanes_used &BIT (v))pr_warn ("%s: duplicated lane %u in clock-lanes\n" , node->full_name, v); lanes_used |=BIT (v); - - bus->clock_lane = v; - have_clk_lane = true; } +return 0 ; +} + +static int v4l2_of_parse_csi2_bus (const struct device_node *node, +struct v4l2_of_endpoint *endpoint) +{ +struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2; +bool have_clk_lane = false; +unsigned int flags =0 ; +int rval; +u32 v; + + rval =v4l2_of_parse_lanes (node, &bus->clock_lane, &have_clk_lane, + bus->data_lanes, bus->lane_polarities, + &bus->num_data_lanes, +ARRAY_SIZE (bus->data_lanes)); +if (rval) +return rval; + +BUILD_BUG_ON (1 +ARRAY_SIZE (bus->data_lanes) + !=ARRAY_SIZE (bus->lane_polarities)); +if (of_get_property (node,"clock-noncontinuous" , &v)) flags |=V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK ;else if (have_clk_lane || bus->num_data_lanes >0 )
@@ -139,6 +178,35 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node, } +void v4l2_of_parse_csi1_bus (const struct device_node *node, +struct v4l2_of_endpoint *endpoint, +enum v4l2_of_bus_type bus_type) +{ +struct v4l2_of_bus_mipi_csi1 *bus = &endpoint->bus.mipi_csi1; +u32 v; + +v4l2_of_parse_lanes (node, &bus->clock_lane,NULL , + &bus->data_lane, bus->lane_polarity, +NULL ,1 ); + +if (!of_property_read_u32 (node,"clock-inv" , &v)) + bus->clock_inv = v; + +if (!of_property_read_u32 (node,"strobe" , &v)) + bus->strobe = v; + +if (!of_property_read_u32 (node,"data-lane" , &v)) + bus->data_lane = v; + +if (!of_property_read_u32 (node,"clock-lane" , &v)) + bus->clock_lane = v; + +if (bus_type ==V4L2_OF_BUS_TYPE_CSI1 ) + endpoint->bus_type =V4L2_MBUS_CSI1 ; +else + endpoint->bus_type =V4L2_MBUS_CCP2 ; +} +/** * v4l2_of_parse_endpoint() - parse all endpoint node properties * @node: pointer to endpoint device_node
@@ -162,6 +230,7 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,int v4l2_of_parse_endpoint (const struct device_node *node,struct v4l2_of_endpoint *endpoint) { +u32 bus_type =0 ;int rval;of_graph_parse_endpoint (node, &endpoint->base);
@@ -169,17 +238,32 @@ int v4l2_of_parse_endpoint(const struct device_node *node,memset (&endpoint->bus_type,0 ,sizeof (*endpoint) - offsetof(typeof(*endpoint), bus_type)); - rval =v4l2_of_parse_csi_bus (node, endpoint); -if (rval) -return rval; -/* -* Parse the parallel video bus properties only if none -* of the MIPI CSI-2 specific properties were found. -*/ -if (endpoint->bus.mipi_csi2.flags ==0 ) -v4l2_of_parse_parallel_bus (node, endpoint); + rval =of_property_read_u32 (node,"bus-type" , &bus_type); +if (bus_type ==0 ) { + endpoint->bus_type =0 ; + rval =v4l2_of_parse_csi2_bus (node, endpoint); +if (rval) +return rval; +/* +* Parse the parallel video bus properties only if none +* of the MIPI CSI-2 specific properties were found. +*/ +if (endpoint->bus.mipi_csi2.flags ==0 ) +v4l2_of_parse_parallel_bus (node, endpoint); + +return 0 ; + } -return 0 ; +switch (bus_type) { +case V4L2_OF_BUS_TYPE_CSI1 : +case V4L2_OF_BUS_TYPE_CCP2 : +v4l2_of_parse_csi1_bus (node, endpoint, bus_type); +return 0 ; +default : +pr_warn ("bad bus-type %u, device_node \"%s\"\n" , + bus_type, node->full_name); +return -EINVAL ; + } }EXPORT_SYMBOL (v4l2_of_parse_endpoint);
Signature · 6 lines
2.1.4 -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 11 lines · Pavel Machek
From: Sebastian Reichel <[email protected]>
If
v4l2_device_register_subdev_nodes()is called multiple times, it is better to return early than corrupt memory.Without this, exposure / gain controls do not work in the camera application on N900.
Signed-off-by Sebastian Reichel <[email protected]>Signed-off-by Ivaylo Dimitrov <[email protected]>Signed-off-by Pavel Machek <[email protected]>
Can I get some updates/feedback here?
You liked this one and whole series should be ready...
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi Pavel,
Quoted 11 lines · Pavel Machek
Hi!
Quoted 8 lines · Pavel Machek
From: Sebastian Reichel <[email protected]>
If
v4l2_device_register_subdev_nodes()is called multiple times, it is better to return early than corrupt memory.Without this, exposure / gain controls do not work in the camera application on N900.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Sebastian Reichel <[email protected]>Signed-off-by Ivaylo Dimitrov <[email protected]>Signed-off-by Pavel Machek <[email protected]>Can I get some updates/feedback here?
You liked this one and whole series should be ready...
:-)
I was just rebasing the CCP2 support on the fwnode patchset.
I'm just pushing the result here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=ccp2>
I've tested ACPI, will test DT soon...
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Quoted 1 line · Sakari Ailus
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Quoted 4 lines · Sakari Ailus
Quoted 1 line · Sakari Ailus
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
Quoted 4 lines · Sakari Ailus
Quoted 1 line · Sakari Ailus
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Hi!
Quoted 13 lines · Sakari Ailus
Quoted 11 lines · Pavel Machek
Quoted 4 lines · Sakari Ailus
Quoted 1 line · Sakari Ailus
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Quoted 5 lines
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Ok, thanks, I got CSI-1 support to compile.
I'm now fighting with subdevices support. Camera flash and autofocus coil really should be subdevices of the ISP, right?
Do you have any solution for that? [I need it for my userspace to work, and porting the old one looks like lot of fun (tm) :-(].
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 13 lines · Sakari Ailus
Quoted 11 lines · Pavel Machek
Quoted 4 lines · Sakari Ailus
Quoted 1 line · Sakari Ailus
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Quoted 5 lines
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 20 lines · Pavel Machek
Quoted 13 lines · Sakari Ailus
Quoted 11 lines · Pavel Machek
Quoted 4 lines · Sakari Ailus
Quoted 1 line · Sakari Ailus
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Quoted 5 lines
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Quoted 6 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
I guess they don't end up matching in the async list.
I think we need to make the non-sensor sub-device support more generic; it's not just the OMAP 3 ISP that needs it. I think we need to document the property for the flash phandle as well; I can write one, or refresh an existing one that I believe already exists.
How about calling it either simply "flash" or "camera-flash"? Similarly for lens: "lens" or "camera-lens". I have a vague feeling the "camera-" prefix is somewhat redundant, so I'd just go for "flash" or "lens".
At the very least the property names must be generic (not hardware dependent) as this kind of functionality should be present in the framework rather than in individual drivers. That'll be for later though.
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
Hi!
Quoted 10 lines
Quoted 6 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
Yes.
Quoted 1 line
I guess they don't end up matching in the async list.
How should they get to the async list?
Quoted 8 lines
I think we need to make the non-sensor sub-device support more generic; it's not just the OMAP 3 ISP that needs it. I think we need to document the property for the flash phandle as well; I can write one, or refresh an existing one that I believe already exists.
How about calling it either simply "flash" or "camera-flash"? Similarly for lens: "lens" or "camera-lens". I have a vague feeling the "camera-" prefix is somewhat redundant, so I'd just go for "flash" or "lens".
Actually, I'd go for "flash" and "focus-coil". There may be other lens properties, such as zoom, mirror movement, lens identification,
...
Quoted 4 lines
At the very least the property names must be generic (not hardware dependent) as this kind of functionality should be present in the framework rather than in individual drivers. That'll be for later though.
Agreed, that would be nice.
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
I believe I can find the patch. But I'm not sure if I can port it to the fwnode infrastructure anytime soon...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
Hi!
Quoted 8 lines
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
I believe I can find the patch. But I'm not sure if I can port it to the fwnode infrastructure anytime soon...
Here is the (unported) patch.
Maybe this helps,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
In reply to Pavel MachekMoi! :-)
Quoted 13 lines · Pavel Machek
Hi!
Quoted 10 lines
Quoted 6 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
Quoted 5 lines
Yes.
Quoted 1 line
I guess they don't end up matching in the async list.
How should they get to the async list?
The patch you referred to does that. The problem is, it does make the bus configuration a pointer as well. There should be two patches. That's not a lot of work to separate them though. But it should be done.
Quoted 6 lines
Quoted 6 lines
I think we need to make the non-sensor sub-device support more generic; it's not just the OMAP 3 ISP that needs it. I think we need to document the property for the flash phandle as well; I can write one, or refresh an existing one that I believe already exists.
Quoted 7 lines
Quoted 3 lines
How about calling it either simply "flash" or "camera-flash"? Similarly for lens: "lens" or "camera-lens". I have a vague feeling the "camera-" prefix is somewhat redundant, so I'd just go for "flash" or "lens".
Actually, I'd go for "flash" and "focus-coil". There may be other lens properties, such as zoom, mirror movement, lens identification,
...
Good point. Still there may be other ways to move the lens than the voice coil (which sure is cheap), so how about "flash" and "lens-focus"?
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
Ahoj! :-)
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
Quoted 6 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
Yes.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
I guess they don't end up matching in the async list.
How should they get to the async list?
The patch you referred to does that. The problem is, it does make the bus configuration a pointer as well. There should be two patches. That's not a lot of work to separate them though. But it should be done.
Well... This is the line I'm fighting with:
+ of_parse_phandle(dev->of_node, "ti,camera-flashes",
+ flash++)
If someone told me its fwnode equivalent, I might be able to get it to work. Knowing what group_id is and if I could ignore it would help a bit, too :-).
(Also, I'll be glad to test patches :-))
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
I think we need to make the non-sensor sub-device support more generic; it's not just the OMAP 3 ISP that needs it. I think we need to document the property for the flash phandle as well; I can write one, or refresh an existing one that I believe already exists.
How about calling it either simply "flash" or "camera-flash"? Similarly for lens: "lens" or "camera-lens". I have a vague feeling the "camera-" prefix is somewhat redundant, so I'd just go for "flash" or "lens".
Quoted 6 lines
Quoted 3 lines
Actually, I'd go for "flash" and "focus-coil". There may be other lens properties, such as zoom, mirror movement, lens identification,
...Good point. Still there may be other ways to move the lens than the voice coil (which sure is cheap), so how about "flash" and "lens-focus"?
Sounds good to me.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
Hyvää iltaa!
Quoted 28 lines · Pavel Machek
Ahoj! :-)
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
Quoted 6 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
Yes.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
I guess they don't end up matching in the async list.
How should they get to the async list?
The patch you referred to does that. The problem is, it does make the bus configuration a pointer as well. There should be two patches. That's not a lot of work to separate them though. But it should be done.
Well... This is the line I'm fighting with:
+ of_parse_phandle(dev->of_node, "ti,camera-flashes",
(quoted diff) +1
-0+ flash++)
Quoted 3 lines
If someone told me its fwnode equivalent, I might be able to get it to work. Knowing what
group_idis and if I could ignore it would help a bit, too :-).
Right.
ACPI does not have equivalents for OF phandles. That's the background of the problem. The port and endpoint references are a bit special: there'a a device reference and indices of the port and the endpoint nodes.
I think you can just use the OF API for the time being until we define how to describe flash devices with ACPI. The difference with ACPI will be visible there almost no matter what do you do there, which is one more reason to have that functionality in the framework (and not drivers).
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
In reply to Sakari AilusDobry den! :-)
Quoted 31 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
Quoted 5 lines
Yes.
Quoted 1 line
I guess they don't end up matching in the async list.
How should they get to the async list?
The patch you referred to does that. The problem is, it does make the bus configuration a pointer as well. There should be two patches. That's not a lot of work to separate them though. But it should be done.
Quoted 10 lines
Quoted 9 lines
I think we need to make the non-sensor sub-device support more generic; it's not just the OMAP 3 ISP that needs it. I think we need to document the property for the flash phandle as well; I can write one, or refresh an existing one that I believe already exists.
How about calling it either simply "flash" or "camera-flash"? Similarly for lens: "lens" or "camera-lens". I have a vague feeling the "camera-" prefix is somewhat redundant, so I'd just go for "flash" or "lens".
Quoted 6 lines
Quoted 3 lines
Actually, I'd go for "flash" and "focus-coil". There may be other lens properties, such as zoom, mirror movement, lens identification,
...Good point. Still there may be other ways to move the lens than the voice coil (which sure is cheap), so how about "flash" and "lens-focus"?
Ok, so something like this? (Yes, needs binding documentation and you wanted it in the core.. can fix.)
BTW, fwnode_handle_put() seems to be missing in the success path of isp_fwnodes_parse() -- can you check that?
Best regards,
Pavel
drivers/media/platform/omap3isp/isp.c +64 -1
@@ -2114,7 +2114,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, buscfg->bus.ccp2.lanecfg.data[0 ].pol = vfwn.bus.mipi_csi1.lane_polarity[1 ]; -dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" ,0 , buscfg->bus.ccp2.lanecfg.data[0 ].pol, buscfg->bus.ccp2.lanecfg.data[0 ].pos);
@@ -2162,10 +2162,64 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,return 0 ; } +static int camera_subdev_parse (struct device *dev,struct v4l2_async_notifier *notifier, +const char *key) +{ +struct device_node *node; +struct isp_async_subdev *isd; + +printk ("Looking for %s\n" , key); + + node =of_parse_phandle (dev->of_node, key,0 ); +if (!node) +return 0 ; + +printk ("Having subdevice: %p\n" , node); + + isd =devm_kzalloc (dev,sizeof (*isd),GFP_KERNEL ); +if (!isd) +return -ENOMEM ; + + notifier->subdevs[notifier->num_subdevs] = &isd->asd; + + isd->asd.match.of.node = node; +if (!isd->asd.match.of.node) { +dev_warn (dev,"bad remote port parent\n" ); +return -EIO ; + } + + isd->asd.match_type =V4L2_ASYNC_MATCH_OF ; + notifier->num_subdevs++; + +return 0 ; +} + +static int camera_subdevs_parse (struct device *dev,struct v4l2_async_notifier *notifier, +int max) +{ +int res =0 ; + +printk ("Going through camera-flashes\n" ); +if (notifier->num_subdevs < max) { + res =camera_subdev_parse (dev, notifier,"flash" ); +if (res) +return res; + } + +if (notifier->num_subdevs < max) { + res =camera_subdev_parse (dev, notifier,"lens-focus" ); +if (res) +return res; + } + +return 0 ; +} +static int isp_fwnodes_parse (struct device *dev,struct v4l2_async_notifier *notifier) {struct fwnode_handle *fwn =NULL ; +int res =0 ; notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );
@@ -2199,6 +2253,15 @@ static int isp_fwnodes_parse(struct device *dev, notifier->num_subdevs++; } +/* FIXME: missing put in the success path? */ + + res =camera_subdevs_parse (dev, notifier,ISP_MAX_SUBDEVS ); +if (res) + goto error; + +if (notifier->num_subdevs ==ISP_MAX_SUBDEVS ) { +printk ("isp: Maybe too many devices?\n" ); + }return notifier->num_subdevs; error:
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
Quoted 1 line · Pavel Machek
Dobry den! :-)
Huomenta! :-)
Quoted 36 lines
Quoted 36 lines
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Ok, I got the camera sensor to work. No subdevices support, so I don't have focus (etc) working, but that's a start. I also had to remove video-bus-switch support; but I guess it will be easier to use video-multiplexer patches...
I'll have patches over weekend.
I briefly looked at what's there --- you do miss the video nodes for the non-sensor sub-devices, and they also don't show up in the media graph, right?
Quoted 5 lines
Yes.
Quoted 1 line
I guess they don't end up matching in the async list.
How should they get to the async list?
The patch you referred to does that. The problem is, it does make the bus configuration a pointer as well. There should be two patches. That's not a lot of work to separate them though. But it should be done.
Quoted 13 lines
Quoted 9 lines
I think we need to make the non-sensor sub-device support more generic; it's not just the OMAP 3 ISP that needs it. I think we need to document the property for the flash phandle as well; I can write one, or refresh an existing one that I believe already exists.
How about calling it either simply "flash" or "camera-flash"? Similarly for lens: "lens" or "camera-lens". I have a vague feeling the "camera-" prefix is somewhat redundant, so I'd just go for "flash" or "lens".
Actually, I'd go for "flash" and "focus-coil". There may be other lens properties, such as zoom, mirror movement, lens identification,
...
Quoted 8 lines
Quoted 2 lines
Good point. Still there may be other ways to move the lens than the voice coil (which sure is cheap), so how about "flash" and "lens-focus"?
Ok, so something like this? (Yes, needs binding documentation and you wanted it in the core.. can fix.)
BTW,
fwnode_handle_put()seems to be missing in the success path ofisp_fwnodes_parse()-- can you check that?
Where exactly? I noticed that if notifier->num_subdevs hits the limit the last node isn't put properly. I'll fix that. Is that what you meant?
Quoted 10 lines
Best regards,
Paveldrivers/media/platform/omap3isp/isp.c +0
-0
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2117
Quoted 5 lines
drivers/media/platform/omap3isp/isp.c +1
-1@@ -2114,7 +2114,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, buscfg->bus.ccp2.lanecfg.data[0 ].pol = vfwn.bus.mipi_csi1.lane_polarity[1 ]; - dev_dbg(dev, "data lane %u polarity %u, pos %u\n", i, + dev_dbg(dev, "data lane %u polarity %u, pos %u\n", 0,
Why?
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c +0
-0buscfg->bus.ccp2.lanecfg.data[0 ].pol, buscfg->bus.ccp2.lanecfg.data[0].pos);@@ -2162,10 +2162,64 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,return 0 ; }
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2173
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +9
-0+static int camera_subdev_parse (struct device *dev,struct v4l2_async_notifier *notifier, +const char *key) +{ +struct device_node *node; +struct isp_async_subdev *isd; + +printk ("Looking for %s\n" , key); + + node =of_parse_phandle (dev->of_node, key,0 );
There may be more than one flash associated with a sensor. Speaking of which --- how is it associated to the sensors?
One way to do this could be to simply move the flash property to the sensor OF node. We could have it here, too, if the flash was not associated with any sensor, but I doubt that will ever be needed.
This really calls fork moving this part to the framework away from drivers.
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2186
Quoted 13 lines
drivers/media/platform/omap3isp/isp.c +13
-0+if (!node) +return 0 ; + +printk ("Having subdevice: %p\n" , node); + + isd =devm_kzalloc (dev,sizeof (*isd),GFP_KERNEL ); +if (!isd) +return -ENOMEM ; + + notifier->subdevs[notifier->num_subdevs] = &isd->asd; + + isd->asd.match.of.node = node; +if (!isd->asd.match.of.node) {
You should check node here first.
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2190
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +4
-0+dev_warn (dev,"bad remote port parent\n" ); +return -EIO ; + } +
And then assign it here.
isd->asd.match.fwnode.fwn = of_fwnode_handle(node);
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2191
Quoted 1 line
drivers/media/platform/omap3isp/isp.c +1
-0+ isd->asd.match_type =V4L2_ASYNC_MATCH_OF ;
V4L2_ASYNC_MATCH_FWNODE, please.
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2200
Quoted 9 lines
drivers/media/platform/omap3isp/isp.c +9
-0+ notifier->num_subdevs++; + +return 0 ; +} + +static int camera_subdevs_parse (struct device *dev,struct v4l2_async_notifier *notifier, +int max) +{ +int res =0 ;
No need to assign res here.
Quoted 43 lines
drivers/media/platform/omap3isp/isp.c +27
-0+ +printk ("Going through camera-flashes\n" ); +if (notifier->num_subdevs < max) { + res =camera_subdev_parse (dev, notifier,"flash" ); +if (res) +return res; + } + +if (notifier->num_subdevs < max) { + res =camera_subdev_parse (dev, notifier,"lens-focus" ); +if (res) +return res; + } + +return 0 ; +} +static int isp_fwnodes_parse (struct device *dev,struct v4l2_async_notifier *notifier) {struct fwnode_handle *fwn =NULL ; +int res =0 ; notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );@@ -2199,6 +2253,15 @@ static int isp_fwnodes_parse(struct device *dev, notifier->num_subdevs++; } +/* FIXME: missing put in the success path? */ + + res =camera_subdevs_parse (dev, notifier,ISP_MAX_SUBDEVS ); +if (res) + goto error; + +if (notifier->num_subdevs ==ISP_MAX_SUBDEVS ) { +printk ("isp: Maybe too many devices?\n" ); + }return notifier->num_subdevs; error:
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
Quoted 4 lines · Sakari Ailus
Quoted 1 line · Pavel Machek
Dobry den! :-)
Huomenta! :-)
Dobry vecer! :-).
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
Good point. Still there may be other ways to move the lens than the voice coil (which sure is cheap), so how about "flash" and "lens-focus"?
Ok, so something like this? (Yes, needs binding documentation and you wanted it in the core.. can fix.)
BTW,
fwnode_handle_put()seems to be missing in the success path ofisp_fwnodes_parse()-- can you check that?Where exactly? I noticed that if
notifier->num_subdevshits the limit the last node isn't put properly. I'll fix that. Is that what you meant?
I guess I'm confused. I see no put on the success path. Maybe it is put somewhere out of the function where I did not look... is the reference held while the driver is running
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2117
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +1
-1@@ -2114,7 +2114,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, buscfg->bus.ccp2.lanecfg.data[0 ].pol = vfwn.bus.mipi_csi1.lane_polarity[1 ]; - dev_dbg(dev, "data lane %u polarity %u, pos %u\n", i, + dev_dbg(dev, "data lane %u polarity %u, pos %u\n", 0,Why?
I was printing uninitialized / unused variable, which is a no-no (and gcc complains). I guess I should do a separate patch.
Quoted 7 lines
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +0
-0buscfg->bus.ccp2.lanecfg.data[0 ].pol, buscfg->bus.ccp2.lanecfg.data[0].pos);@@ -2162,10 +2162,64 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,return 0 ; }
Quoted 12 lines
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2173
Quoted 9 lines
drivers/media/platform/omap3isp/isp.c +9
-0+static int camera_subdev_parse (struct device *dev,struct v4l2_async_notifier *notifier, +const char *key) +{ +struct device_node *node; +struct isp_async_subdev *isd; + +printk ("Looking for %s\n" , key); + + node =of_parse_phandle (dev->of_node, key,0 );There may be more than one flash associated with a sensor. Speaking of which --- how is it associated to the sensors?
Ok, more then one flash I can understand (will fix).
Quoted 6 lines
One way to do this could be to simply move the flash property to the sensor OF node. We could have it here, too, if the flash was not associated with any sensor, but I doubt that will ever be needed.
This really calls fork moving this part to the framework away from drivers.
The rest I don't get :-(. The flash is likely connected over i2c, so it should not become child node of omap3isp.
And yes, I agree we want to move it into the framework. Lets agree on how it should work and where to put it, I'll debug it here then move it...
Quoted 7 lines
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +7
-0+if (!node) +return 0 ; + +printk ("Having subdevice: %p\n" , node); + + isd =devm_kzalloc (dev,sizeof (*isd),GFP_KERNEL ); +if (!isd)
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2186
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c +6
-0+return -ENOMEM ; + + notifier->subdevs[notifier->num_subdevs] = &isd->asd; + + isd->asd.match.of.node = node; +if (!isd->asd.match.of.node) {You should check node here first.
Umm. I did, above. This can't happen, AFAICT.
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2190
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +4
-0+dev_warn (dev,"bad remote port parent\n" ); +return -EIO ; + } +And then assign it here.
Quoted 5 lines
isd->asd.match.fwnode.fwn=of_fwnode_handle(node);drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2191
Quoted 1 line
drivers/media/platform/omap3isp/isp.c +1
-0+ isd->asd.match_type =V4L2_ASYNC_MATCH_OF ;
V4L2_ASYNC_MATCH_FWNODE, please.
Ok. Lets see if it still works after the changes :-)... it does, good.
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2200
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +4
-0+static int camera_subdevs_parse (struct device *dev,struct v4l2_async_notifier *notifier, +int max) +{ +int res =0 ;No need to assign res here.
Ok.
Thanks and best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: camera subdevice support was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times
In reply to Sakari AilusČágo Belo Šílenci! :-)
Quoted 13 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+static int camera_subdev_parse(struct device *dev, struct v4l2_async_notifier *notifier, + const char *key) +{ + struct device_node *node; + struct isp_async_subdev *isd; + + printk("Looking for %s\n", key); + + node = of_parse_phandle(dev->of_node, key, 0);There may be more than one flash associated with a sensor. Speaking of which --- how is it associated to the sensors?
Quoted 3 lines
One way to do this could be to simply move the flash property to the sensor OF node. We could have it here, too, if the flash was not associated with any sensor, but I doubt that will ever be needed.
I don't know what you mean here. Anyway, here's updated version.
Best regards,
Pavel
drivers/media/platform/omap3isp/isp.c +56 -0
@@ -2162,10 +2162,57 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,return 0 ; } +static int camera_subdev_parse (struct device *dev,struct v4l2_async_notifier *notifier, +const char *key,int max) +{ +struct device_node *node; +struct isp_async_subdev *isd; +int num =0 ; + +printk ("Looking for %s\n" , key); + +while (notifier->num_subdevs < max) { + node =of_parse_phandle (dev->of_node, key, num++); +if (!node) +return 0 ; + +printk ("Having subdevice: %p\n" , node); + + isd =devm_kzalloc (dev,sizeof (*isd),GFP_KERNEL ); +if (!isd) +return -ENOMEM ; + + notifier->subdevs[notifier->num_subdevs] = &isd->asd; + + isd->asd.match.fwnode.fwn =of_fwnode_handle (node); + isd->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; + notifier->num_subdevs++; + } + +return 0 ; +} + +static int camera_subdevs_parse (struct device *dev,struct v4l2_async_notifier *notifier, +int max) +{ +int res; + + res =camera_subdev_parse (dev, notifier,"flash" , max); +if (res) +return res; + + res =camera_subdev_parse (dev, notifier,"lens-focus" , max); +if (res) +return res; + +return 0 ; +} +static int isp_fwnodes_parse (struct device *dev,struct v4l2_async_notifier *notifier) {struct fwnode_handle *fwn =NULL ; +int res; notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );
@@ -2199,6 +2246,15 @@ static int isp_fwnodes_parse(struct device *dev, notifier->num_subdevs++; } +/* FIXME: missing put in the success path? */ + + res =camera_subdevs_parse (dev, notifier,ISP_MAX_SUBDEVS ); +if (res) + goto error; + +if (notifier->num_subdevs ==ISP_MAX_SUBDEVS ) { +printk ("isp: Maybe too many devices?\n" ); + }return notifier->num_subdevs; error:
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
In reply to Sakari AilusHi!
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
Something like this?
Pavel
commit df9141c66678b549fac9d143bd55ed0b242cf36e
Author: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100
Turn bus in struct isp_async_subdev into pointer; some of our subdevs (flash, focus) will not need bus configuration.
drivers/media/platform/omap3isp/isp.c +8 -2
@@ -2030,12 +2030,18 @@ enum isp_of_phy {static int isp_fwnode_parse (struct device *dev,struct fwnode_handle *fwn,struct isp_async_subdev *isd) { -struct isp_bus_cfg *buscfg = &isd->bus; +struct isp_bus_cfg *buscfg;struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret;bool csi1 = false; + buscfg =devm_kzalloc (dev,sizeof (*isd->bus),GFP_KERNEL ); +if (!buscfg) +return -ENOMEM ; + + isd->bus = buscfg; + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret;
@@ -2246,7 +2252,7 @@ static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async, container_of(asd, struct isp_async_subdev, asd); isd->sd = subdev; - isd->sd->host_priv = &isd->bus; + isd->sd->host_priv = isd->bus;return 0 ; }
drivers/media/platform/omap3isp/isp.h +1 -1
@@ -228,7 +228,7 @@ struct isp_device {struct isp_async_subdev {struct v4l2_subdev *sd; -struct isp_bus_cfg bus; +struct isp_bus_cfg *bus;struct v4l2_async_subdev asd; };
drivers/media/platform/omap3isp/ispcsiphy.c +1 -1
@@ -202,7 +202,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)struct isp_async_subdev *isd =container_of (pipe->external->asd, struct isp_async_subdev, asd); - buscfg = &isd->bus; + buscfg = isd->bus; } if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
Hi Pavel,
Quoted 11 lines · Pavel Machek
Hi!
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
Something like this?
Pavel
Quoted 8 lines
commit
df9141c66678b549fac9d143bd55ed0b242cf36eAuthor: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100Turn bus in struct
isp_async_subdevinto pointer; some of our subdevs (flash, focus) will not need bus configuration.Signed-off-by Pavel Machek <[email protected]>
I applied this to the ccp2 branch with an improved patch description.
Quoted 62 lines
drivers/media/platform/omap3isp/isp.c +8
-2@@ -2030,12 +2030,18 @@ enum isp_of_phy {static int isp_fwnode_parse (struct device *dev,struct fwnode_handle *fwn,struct isp_async_subdev *isd) { -struct isp_bus_cfg *buscfg = &isd->bus; +struct isp_bus_cfg *buscfg;struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret;bool csi1 = false; + buscfg =devm_kzalloc (dev,sizeof (*isd->bus),GFP_KERNEL ); +if (!buscfg) +return -ENOMEM ; + + isd->bus = buscfg; + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret;@@ -2246,7 +2252,7 @@ static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async, container_of(asd, struct isp_async_subdev, asd); isd->sd = subdev; - isd->sd->host_priv = &isd->bus; + isd->sd->host_priv = isd->bus;return 0 ; }drivers/media/platform/omap3isp/isp.h +1
-1@@ -228,7 +228,7 @@ struct isp_device {struct isp_async_subdev {struct v4l2_subdev *sd; -struct isp_bus_cfg bus; +struct isp_bus_cfg *bus;struct v4l2_async_subdev asd; };drivers/media/platform/omap3isp/ispcsiphy.c +1
-1@@ -202,7 +202,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)struct isp_async_subdev *isd =container_of (pipe->external->asd, struct isp_async_subdev, asd); - buscfg = &isd->bus; + buscfg = isd->bus; } if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
Hi!
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
Something like this?
commit
df9141c66678b549fac9d143bd55ed0b242cf36eAuthor: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100
Quoted 7 lines
Quoted 4 lines
Turn bus in struct
isp_async_subdevinto pointer; some of our subdevs (flash, focus) will not need bus configuration.Signed-off-by Pavel Machek <[email protected]>I applied this to the ccp2 branch with an improved patch description.
Thanks!
[But the important part is to get subdevices to work on ccp2 based branch, and it still fails to work at all if I attempt to enable them. I'd like to understand why...]
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
Hi Pavel,
Quoted 19 lines · Pavel Machek
Hi!
Quoted 17 lines
Quoted 16 lines
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
Something like this?
commit
df9141c66678b549fac9d143bd55ed0b242cf36eAuthor: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100Turn bus in struct
isp_async_subdevinto pointer; some of our subdevs (flash, focus) will not need bus configuration.Signed-off-by Pavel Machek <[email protected]>
Quoted 8 lines
Quoted 2 lines
I applied this to the ccp2 branch with an improved patch description.
Thanks!
[But the important part is to get subdevices to work on ccp2 based branch, and it still fails to work at all if I attempt to enable them. I'd like to understand why...]
Did you add the flash / lens to the async list? The patches currently in the ccp branch do not include that --- it should be in parsing the flash / lens-focus properties in omap3isp device's node.
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
Hi!
Quoted 22 lines
Quoted 22 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can't find it right now anyway.
Something like this?
commit
df9141c66678b549fac9d143bd55ed0b242cf36eAuthor: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100Quoted 7 lines
Quoted 4 lines
Turn bus in struct
isp_async_subdevinto pointer; some of our subdevs (flash, focus) will not need bus configuration.Signed-off-by Pavel Machek <[email protected]>I applied this to the ccp2 branch with an improved patch description.
Thanks!
Quoted 7 lines
Quoted 3 lines
[But the important part is to get subdevices to work on ccp2 based branch, and it still fails to work at all if I attempt to enable them. I'd like to understand why...]
Did you add the flash / lens to the async list? The patches currently in the ccp branch do not include that --- it should be in parsing the flash / lens-focus properties in omap3isp device's node.
I retried, and it fails different way than I assumed. I might be able to debug this one as sensor (and mplayer) still works.
Best regards,
Pavel
--
This is what subdevs support should look like, I guess; but I don't know fwnode stuff well enough.
drivers/media/platform/omap3isp/isp.c +38 -0
@@ -2166,6 +2166,8 @@ static int isp_fwnodes_parse(struct device *dev, struct v4l2_async_notifier *notifier) {struct fwnode_handle *fwn =NULL ; +struct device_node *node; +int flash =0 ; notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );
@@ -2199,6 +2201,42 @@ static int isp_fwnodes_parse(struct device *dev, notifier->num_subdevs++; } +printk ("Going through camera-flashes\n" ); +while (notifier->num_subdevs <ISP_MAX_SUBDEVS ) { +/* FIXME: fwnode_graph_get_remote_endpoint() +(fwn = fwnode_graph_get_next_endpoint(device_fwnode_handle(dev), fwn, )) */ +struct isp_async_subdev *isd; + + node =of_parse_phandle (dev->of_node,"ti,camera-flashes" , flash++); + flash++; +if (!node) +break ; + +printk ("Having subdevice: %p\n" , node); + +#if 1 + isd =devm_kzalloc (dev,sizeof (*isd),GFP_KERNEL ); +if (!isd) + goto error; + + notifier->subdevs[notifier->num_subdevs] = &isd->asd; + + + isd->asd.match.of.node = node; +if (!isd->asd.match.of.node) { +dev_warn (dev,"bad remote port parent\n" ); + goto error; + } + + isd->asd.match_type =V4L2_ASYNC_MATCH_OF ; + notifier->num_subdevs++; +#endif + } + + +if (notifier->num_subdevs ==ISP_MAX_SUBDEVS ) { +printk ("isp: Maybe too many devices?\n" ); + }return notifier->num_subdevs; error:
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
In reply to Sakari AilusHi Sakari,
Quoted 40 lines · On Thursday 02 Mar 2017 16:16:17 Sakari Ailus wrote:
Quoted 12 lines · Pavel Machek
Hi!
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can'tfind it right now anyway.
Something like this?
Pavel
Quoted 8 lines
commit
df9141c66678b549fac9d143bd55ed0b242cf36eAuthor: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100Turn bus in struct
isp_async_subdevinto pointer; some of our subdevs (flash, focus) will not need bus configuration.Signed-off-by Pavel Machek <[email protected]>I applied this to the ccp2 branch with an improved patch description.
Quoted 16 lines
(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex 8a456d4..36bd359 100644drivers/media/platform/omap3isp/isp.c +1
-1@@ -2030,12 +2030,18 @@ enum isp_of_phy {static int isp_fwnode_parse (struct device *dev,struct fwnode_handle *fwn,struct isp_async_subdev *isd) { -struct isp_bus_cfg *buscfg = &isd->bus; +struct isp_bus_cfg *buscfg;
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2039
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c +1
-0struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret;bool csi1 = false; + buscfg =devm_kzalloc (dev,sizeof (*isd->bus),GFP_KERNEL );
Given that you recently get rid of devm_kzalloc() in the driver, let's not introduce a new one here.
Quoted 10 lines
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +5
-0+if (!buscfg) +return -ENOMEM ; + + isd->bus = buscfg; + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret;
[snip]
Signature · 3 lines
Regards, Laurent Pinchart
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
Hi Laurent,
Quoted 48 lines · Laurent Pinchart
Hi Sakari,
Quoted 45 lines · On Thursday 02 Mar 2017 16:16:17 Sakari Ailus wrote:
Quoted 12 lines · Pavel Machek
Hi!
Quoted 5 lines
Making the sub-device bus configuration a pointer should be in a separate patch. It makes sense since the entire configuration is not valid for all sub-devices attached to the ISP anymore. I think it originally was a separate patch, but they probably have been merged at some point. I can'tfind it right now anyway.
Something like this?
Pavel
Quoted 8 lines
commit
df9141c66678b549fac9d143bd55ed0b242cf36eAuthor: Pavel <[email protected]> Date: Wed Mar 1 13:27:56 2017 +0100Turn bus in struct
isp_async_subdevinto pointer; some of our subdevs (flash, focus) will not need bus configuration.Signed-off-by Pavel Machek <[email protected]>I applied this to the ccp2 branch with an improved patch description.
Quoted 21 lines
(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex 8a456d4..36bd359 100644drivers/media/platform/omap3isp/isp.c +1
-1@@ -2030,12 +2030,18 @@ enum isp_of_phy {static int isp_fwnode_parse (struct device *dev,struct fwnode_handle *fwn,struct isp_async_subdev *isd) { -struct isp_bus_cfg *buscfg = &isd->bus; +struct isp_bus_cfg *buscfg;struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret;bool csi1 = false;
Quoted 4 lines
Quoted 1 line
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2039
Quoted 1 line
drivers/media/platform/omap3isp/isp.c +1
-0+ buscfg =devm_kzalloc (dev,sizeof (*isd->bus),GFP_KERNEL );Given that you recently get rid of
devm_kzalloc()in the driver, let's not introduce a new one here.
That's certainly a valid point.
Still, the entire async sub-devices array is allocated with devm_() allocation functions still; that part wasn't addressed by the patchset mostly removing devm_() memory allocation, so this patch does actually not change how the memory is allocated.
Beyond that, I'm not entirely sure whether this is a problem to begin with:
devm resources are released after remove() callback and access to this data structure should only happen as a direct result of user IOCTL. IOCTLs may only be in progress as long as there are open file handles on a device --- and such file handles must be closed until the remove() callback may finish. (Referring to the Oslo meeting notes.)
Some of the above must be still verified; either way, but the options are
clear: either devm must be removed here as well (with the rest) or that it's fine to use it here: from this point of view this patch makes no difference.
Quoted 14 lines
Quoted 11 lines
Quoted 11 lines
drivers/media/platform/omap3isp/isp.c +5
-0+if (!buscfg) +return -ENOMEM ; + + isd->bus = buscfg; + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret;[snip]
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: subdevice config into pointer (was Re: [PATCH 1/4] v4l2: device_register_subdev_nodes: allow calling multiple times)
In reply to Laurent PinchartHi!
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
static int isp_fwnode_parse(struct device *dev, struct
fwnode_handle*fwn,drivers/media/platform/omap3isp/isp.c +1
-1struct isp_async_subdev *isd) { -struct isp_bus_cfg *buscfg = &isd->bus; +struct isp_bus_cfg *buscfg;struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret;bool csi1 = false;
Quoted 4 lines
Quoted 1 line
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2039
Quoted 1 line
drivers/media/platform/omap3isp/isp.c +1
-0+ buscfg =devm_kzalloc (dev,sizeof (*isd->bus),GFP_KERNEL );Given that you recently get rid of
devm_kzalloc()in the driver, let's not introduce a new one here.
What is wrong with devm_kzalloc()?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 12 lines
Quoted 11 lines · Sakari Ailus
Quoted 4 lines · Sakari Ailus
Quoted 1 line
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Quoted 5 lines
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Yes, it seems to work.
Here's a patch. It has checkpatch issues, I can fix them. More support is needed on the ispcsiphy.c side... Could you take (fixed) version of this to your fwnode branch?
Thanks,
Pavel
---
omap3isp: add support for CSI1 bus
drivers/media/platform/omap3isp/isp.c +69 -24
@@ -2032,6 +2034,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret; +int csi1 =0 ; ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)
@@ -2059,38 +2062,82 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,case ISP_OF_PHY_CSIPHY1 :case ISP_OF_PHY_CSIPHY2 : -/* FIXME: always assume CSI-2 for now. */ +switch (vfwn.bus_type) { +case V4L2_MBUS_CSI2 : +dev_dbg (dev,"csi2 configuration\n" ); + csi1 =0 ; +break ; +case V4L2_MBUS_CCP2 : +case V4L2_MBUS_CSI1 : +dev_dbg (dev,"csi1 configuration\n" ); + csi1 =1 ; +break ; +default : +dev_err (dev,"unkonwn bus type\n" ); + } +switch (vfwn.base.port) {case ISP_OF_PHY_CSIPHY1 : - buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY1 ; +else + buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ;break ;case ISP_OF_PHY_CSIPHY2 : - buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY2 ; +else + buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ;break ; +default : +dev_err (dev,"bad port\n" ); } - buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; - buscfg->bus.csi2.lanecfg.clk.pol = - vfwn.bus.mipi_csi2.lane_polarities[0 ]; -dev_dbg (dev,"clock lane polarity %u, pos %u\n" , - buscfg->bus.csi2.lanecfg.clk.pol, - buscfg->bus.csi2.lanecfg.clk.pos); - -for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { - buscfg->bus.csi2.lanecfg.data[i].pos = - vfwn.bus.mipi_csi2.data_lanes[i]; - buscfg->bus.csi2.lanecfg.data[i].pol = - vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +if (csi1) { + buscfg->bus.ccp2.lanecfg.clk.pos = vfwn.bus.mipi_csi1.clock_lane; + buscfg->bus.ccp2.lanecfg.clk.pol = + vfwn.bus.mipi_csi1.lane_polarity[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.ccp2.lanecfg.clk.pol, + buscfg->bus.ccp2.lanecfg.clk.pos); + + buscfg->bus.ccp2.lanecfg.data[0 ].pos =1 ; + buscfg->bus.ccp2.lanecfg.data[0 ].pol =0 ; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, - buscfg->bus.csi2.lanecfg.data[i].pol, - buscfg->bus.csi2.lanecfg.data[i].pos); + buscfg->bus.ccp2.lanecfg.data[0 ].pol, + buscfg->bus.ccp2.lanecfg.data[0 ].pos); + + buscfg->bus.ccp2.strobe_clk_pol = vfwn.bus.mipi_csi1.clock_inv; + buscfg->bus.ccp2.phy_layer = vfwn.bus.mipi_csi1.strobe; + buscfg->bus.ccp2.ccp2_mode = vfwn.bus_type ==V4L2_MBUS_CCP2 ; + buscfg->bus.ccp2.vp_clk_pol =1 ; + + buscfg->bus.ccp2.crc =1 ; + }else { + buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; + buscfg->bus.csi2.lanecfg.clk.pol = + vfwn.bus.mipi_csi2.lane_polarities[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.csi2.lanecfg.clk.pol, + buscfg->bus.csi2.lanecfg.clk.pos); + +for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { + buscfg->bus.csi2.lanecfg.data[i].pos = + vfwn.bus.mipi_csi2.data_lanes[i]; + buscfg->bus.csi2.lanecfg.data[i].pol = + vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, + buscfg->bus.csi2.lanecfg.data[i].pol, + buscfg->bus.csi2.lanecfg.data[i].pos); + } +/* +* FIXME: now we assume the CRC is always there. +* Implement a way to obtain this information from the +* sensor. Frame descriptors, perhaps? +*/ + + buscfg->bus.csi2.crc =1 ; } - -/* -* FIXME: now we assume the CRC is always there. -* Implement a way to obtain this information from the -* sensor. Frame descriptors, perhaps? -*/ - buscfg->bus.csi2.crc =1 ;break ;default :
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 18 lines
Quoted 12 lines
Quoted 11 lines · Sakari Ailus
Quoted 4 lines · Sakari Ailus
Quoted 1 line
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Quoted 5 lines
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Quoted 5 lines
Yes, it seems to work.
Here's a patch. It has checkpatch issues, I can fix them. More support is needed on the
ispcsiphy.cside... Could you take (fixed) version of this to your fwnode branch?
Any feedback would be welcome :-)
Pavel
Quoted 125 lines
omap3isp: add support for CSI1 bus
Signed-off-by Pavel Machek <[email protected]>drivers/media/platform/omap3isp/isp.c +69
-24@@ -2032,6 +2034,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret; +int csi1 =0 ; ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)@@ -2059,38 +2062,82 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,case ISP_OF_PHY_CSIPHY1 :case ISP_OF_PHY_CSIPHY2 : -/* FIXME: always assume CSI-2 for now. */ +switch (vfwn.bus_type) { +case V4L2_MBUS_CSI2 : +dev_dbg (dev,"csi2 configuration\n" ); + csi1 =0 ; +break ; +case V4L2_MBUS_CCP2 : +case V4L2_MBUS_CSI1 : +dev_dbg (dev,"csi1 configuration\n" ); + csi1 =1 ; +break ; +default : +dev_err (dev,"unkonwn bus type\n" ); + } +switch (vfwn.base.port) {case ISP_OF_PHY_CSIPHY1 : - buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY1 ; +else + buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ;break ;case ISP_OF_PHY_CSIPHY2 : - buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY2 ; +else + buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ;break ; +default : +dev_err (dev,"bad port\n" ); } - buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; - buscfg->bus.csi2.lanecfg.clk.pol = - vfwn.bus.mipi_csi2.lane_polarities[0 ]; -dev_dbg (dev,"clock lane polarity %u, pos %u\n" , - buscfg->bus.csi2.lanecfg.clk.pol, - buscfg->bus.csi2.lanecfg.clk.pos); - -for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { - buscfg->bus.csi2.lanecfg.data[i].pos = - vfwn.bus.mipi_csi2.data_lanes[i]; - buscfg->bus.csi2.lanecfg.data[i].pol = - vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +if (csi1) { + buscfg->bus.ccp2.lanecfg.clk.pos = vfwn.bus.mipi_csi1.clock_lane; + buscfg->bus.ccp2.lanecfg.clk.pol = + vfwn.bus.mipi_csi1.lane_polarity[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.ccp2.lanecfg.clk.pol, + buscfg->bus.ccp2.lanecfg.clk.pos); + + buscfg->bus.ccp2.lanecfg.data[0 ].pos =1 ; + buscfg->bus.ccp2.lanecfg.data[0 ].pol =0 ; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, - buscfg->bus.csi2.lanecfg.data[i].pol, - buscfg->bus.csi2.lanecfg.data[i].pos); + buscfg->bus.ccp2.lanecfg.data[0 ].pol, + buscfg->bus.ccp2.lanecfg.data[0 ].pos); + + buscfg->bus.ccp2.strobe_clk_pol = vfwn.bus.mipi_csi1.clock_inv; + buscfg->bus.ccp2.phy_layer = vfwn.bus.mipi_csi1.strobe; + buscfg->bus.ccp2.ccp2_mode = vfwn.bus_type ==V4L2_MBUS_CCP2 ; + buscfg->bus.ccp2.vp_clk_pol =1 ; + + buscfg->bus.ccp2.crc =1 ; + }else { + buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; + buscfg->bus.csi2.lanecfg.clk.pol = + vfwn.bus.mipi_csi2.lane_polarities[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.csi2.lanecfg.clk.pol, + buscfg->bus.csi2.lanecfg.clk.pos); + +for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { + buscfg->bus.csi2.lanecfg.data[i].pos = + vfwn.bus.mipi_csi2.data_lanes[i]; + buscfg->bus.csi2.lanecfg.data[i].pol = + vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, + buscfg->bus.csi2.lanecfg.data[i].pol, + buscfg->bus.csi2.lanecfg.data[i].pos); + } +/* +* FIXME: now we assume the CRC is always there. +* Implement a way to obtain this information from the +* sensor. Frame descriptors, perhaps? +*/ + + buscfg->bus.csi2.crc =1 ; } - -/* -* FIXME: now we assume the CRC is always there. -* Implement a way to obtain this information from the -* sensor. Frame descriptors, perhaps? -*/ - buscfg->bus.csi2.crc =1 ;break ;default :
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi Pavel,
Please find my comments below.
Quoted 63 lines · Pavel Machek
Hi!
Quoted 12 lines
Quoted 11 lines · Sakari Ailus
Quoted 4 lines · Sakari Ailus
Quoted 1 line
I've tested ACPI, will test DT soon...
DT case works, too (Nokia N9).
Hmm. Good to know. Now to figure out how to get N900 case to work...
AFAICT N9 has CSI2, not CSI1 support, right? Some of the core changes seem to be in, so I'll need to figure out which, and will still need omap3isp modifications...
Quoted 5 lines
Indeed, I've only tested for CSI-2 as I have no functional CSI-1 devices.
It's essentially the functionality in the four patches. The data-lane and clock-name properties have been renamed as data-lanes and clock-lanes (i.e. plural) to match the property documentation.
Yes, it seems to work.
Here's a patch. It has checkpatch issues, I can fix them. More support is needed on the
ispcsiphy.cside... Could you take (fixed) version of this to your fwnode branch?Thanks,
Pavel---
omap3isp: add support for CSI1 bus
Signed-off-by Pavel Machek <[email protected]>drivers/media/platform/omap3isp/isp.c +9
-1@@ -2032,6 +2034,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret; +int csi1 =0 ; ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)@@ -2059,38 +2062,82 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,case ISP_OF_PHY_CSIPHY1 :case ISP_OF_PHY_CSIPHY2 : -/* FIXME: always assume CSI-2 for now. */ +switch (vfwn.bus_type) { +case V4L2_MBUS_CSI2 : +dev_dbg (dev,"csi2 configuration\n" ); + csi1 =0 ; +break ; +case V4L2_MBUS_CCP2 : +case V4L2_MBUS_CSI1 : +dev_dbg (dev,"csi1 configuration\n" );
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2081
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +7
-1+ csi1 =1 ; +break ; +default : +dev_err (dev,"unkonwn bus type\n" ); + } +switch (vfwn.base.port) {case ISP_OF_PHY_CSIPHY1 : - buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ; +if (csi1)
You could compare vfwn.bus_type == V4L2_MBUS_CSI2 for this. But if you choose the local variable, please make it bool instead.
Quoted 18 lines
drivers/media/platform/omap3isp/isp.c +9
-5+ buscfg->interface =ISP_INTERFACE_CCP2B_PHY1 ; + else + buscfg->interface = ISP_INTERFACE_CSI2C_PHY1;break ;case ISP_OF_PHY_CSIPHY2 : - buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY2 ; +else + buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ;break ; +default : +dev_err (dev,"bad port\n" ); } - buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; - buscfg->bus.csi2.lanecfg.clk.pol = - vfwn.bus.mipi_csi2.lane_polarities[0 ]; - dev_dbg(dev, "clock lane polarity %u, pos %u\n",
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2096
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +2
-8- buscfg->bus.csi2.lanecfg.clk.pol, - buscfg->bus.csi2.lanecfg.clk.pos); - -for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { - buscfg->bus.csi2.lanecfg.data[i].pos = - vfwn.bus.mipi_csi2.data_lanes[i]; - buscfg->bus.csi2.lanecfg.data[i].pol = - vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +if (csi1) { + buscfg->bus.ccp2.lanecfg.clk.pos = vfwn.bus.mipi_csi1.clock_lane;
Wrap after "="?
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2103
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +7
-0+ buscfg->bus.ccp2.lanecfg.clk.pol = + vfwn.bus.mipi_csi1.lane_polarity[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.ccp2.lanecfg.clk.pol, + buscfg->bus.ccp2.lanecfg.clk.pos); + + buscfg->bus.ccp2.lanecfg.data[0 ].pos =1 ;
Shouldn't this be vfwn.bus.mipi_csi1.data_lane ?
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2104
Quoted 1 line
drivers/media/platform/omap3isp/isp.c +1
-0+ buscfg->bus.ccp2.lanecfg.data[0 ].pol =0 ;
And this one is vfwn.bus.mipi_csi1.lane_polarity[1] .
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2112
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +7
-2+dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, - buscfg->bus.csi2.lanecfg.data[i].pol, - buscfg->bus.csi2.lanecfg.data[i].pos); + buscfg->bus.ccp2.lanecfg.data[0 ].pol, + buscfg->bus.ccp2.lanecfg.data[0 ].pos); + + buscfg->bus.ccp2.strobe_clk_pol = vfwn.bus.mipi_csi1.clock_inv; + buscfg->bus.ccp2.phy_layer = vfwn.bus.mipi_csi1.strobe; + buscfg->bus.ccp2.ccp2_mode = vfwn.bus_type ==V4L2_MBUS_CCP2 ;
The lines over 80 characters should be wrapped.
Quoted 40 lines
drivers/media/platform/omap3isp/isp.c +27
-7+ buscfg->bus.ccp2.vp_clk_pol =1 ; + + buscfg->bus.ccp2.crc =1 ; + }else { + buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; + buscfg->bus.csi2.lanecfg.clk.pol = + vfwn.bus.mipi_csi2.lane_polarities[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.csi2.lanecfg.clk.pol, + buscfg->bus.csi2.lanecfg.clk.pos); + +for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { + buscfg->bus.csi2.lanecfg.data[i].pos = + vfwn.bus.mipi_csi2.data_lanes[i]; + buscfg->bus.csi2.lanecfg.data[i].pol = + vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, + buscfg->bus.csi2.lanecfg.data[i].pol, + buscfg->bus.csi2.lanecfg.data[i].pos); + } +/* +* FIXME: now we assume the CRC is always there. +* Implement a way to obtain this information from the +* sensor. Frame descriptors, perhaps? +*/ + + buscfg->bus.csi2.crc =1 ; } - -/* -* FIXME: now we assume the CRC is always there. -* Implement a way to obtain this information from the -* sensor. Frame descriptors, perhaps? -*/ - buscfg->bus.csi2.crc =1 ;break ;default :
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Hi!
Quoted 1 line
Please find my comments below.
Thanks for quick review, will fix.
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2081
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +1
-1switch (vfwn.base.port) {case ISP_OF_PHY_CSIPHY1 : - buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ; +if (csi1)You could compare vfwn.bus_type ==
V4L2_MBUS_CSI2for this. But if you choose the local variable, please make it bool instead.
I prefer variable, will switch to bool.
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + buscfg->bus.ccp2.lanecfg.data[0].pos = 1;Shouldn't this be vfwn.bus.mipi_csi1.data_lane ?
drivers/media/platform/omap3isp/isp.c static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, · line 2104
Quoted 1 line
drivers/media/platform/omap3isp/isp.c +1
-0+ buscfg->bus.ccp2.lanecfg.data[0 ].pol =0 ;And this one is vfwn.bus.mipi_csi1.lane_polarity[1] .
Thanks for catching this.
Checkpatch issues will be fixed.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 1/1 omap3isp: Parse CSI1 configuration from the device tree.
In reply to Sakari AilusAdd support for parsing CSI1 configuration.
---
Quoted 1 line
Please find my comments below.
Thanks for comments. They are fixed now, plus I fixed the checkpatch stuff that was possible.
It should be ready to apply to the right branch.
drivers/media/platform/omap3isp/isp.c +75 -24
@@ -2032,6 +2032,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,struct v4l2_fwnode_endpoint vfwn;unsigned int i;int ret; +bool csi1 = false; ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)
@@ -2059,38 +2060,88 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn,case ISP_OF_PHY_CSIPHY1 :case ISP_OF_PHY_CSIPHY2 : -/* FIXME: always assume CSI-2 for now. */ +switch (vfwn.bus_type) { +case V4L2_MBUS_CCP2 : +case V4L2_MBUS_CSI1 : +dev_dbg (dev,"csi1 configuration\n" ); + csi1 = true; +break ; +case V4L2_MBUS_CSI2 : +dev_dbg (dev,"csi2 configuration\n" ); + csi1 = false; +break ; +default : +dev_err (dev,"unkonwn bus type\n" ); + } +switch (vfwn.base.port) {case ISP_OF_PHY_CSIPHY1 : - buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY1 ; +else + buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ;break ;case ISP_OF_PHY_CSIPHY2 : - buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY2 ; +else + buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ;break ; +default : +dev_err (dev,"bad port\n" ); } - buscfg->bus.csi2.lanecfg.clk.pos = vfwn.bus.mipi_csi2.clock_lane; - buscfg->bus.csi2.lanecfg.clk.pol = - vfwn.bus.mipi_csi2.lane_polarities[0 ]; -dev_dbg (dev,"clock lane polarity %u, pos %u\n" , - buscfg->bus.csi2.lanecfg.clk.pol, - buscfg->bus.csi2.lanecfg.clk.pos); - -for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { - buscfg->bus.csi2.lanecfg.data[i].pos = - vfwn.bus.mipi_csi2.data_lanes[i]; - buscfg->bus.csi2.lanecfg.data[i].pol = - vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +if (csi1) { + buscfg->bus.ccp2.lanecfg.clk.pos = + vfwn.bus.mipi_csi1.clock_lane; + buscfg->bus.ccp2.lanecfg.clk.pol = + vfwn.bus.mipi_csi1.lane_polarity[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.ccp2.lanecfg.clk.pol, + buscfg->bus.ccp2.lanecfg.clk.pos); + + buscfg->bus.ccp2.lanecfg.data[0 ].pos = + vfwn.bus.mipi_csi1.data_lane; + buscfg->bus.ccp2.lanecfg.data[0 ].pol = + vfwn.bus.mipi_csi1.lane_polarity[1 ]; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, - buscfg->bus.csi2.lanecfg.data[i].pol, - buscfg->bus.csi2.lanecfg.data[i].pos); + buscfg->bus.ccp2.lanecfg.data[0 ].pol, + buscfg->bus.ccp2.lanecfg.data[0 ].pos); + + buscfg->bus.ccp2.strobe_clk_pol = + vfwn.bus.mipi_csi1.clock_inv; + buscfg->bus.ccp2.phy_layer = vfwn.bus.mipi_csi1.strobe; + buscfg->bus.ccp2.ccp2_mode = + vfwn.bus_type ==V4L2_MBUS_CCP2 ; + buscfg->bus.ccp2.vp_clk_pol =1 ; + + buscfg->bus.ccp2.crc =1 ; + }else { + buscfg->bus.csi2.lanecfg.clk.pos = + vfwn.bus.mipi_csi2.clock_lane; + buscfg->bus.csi2.lanecfg.clk.pol = + vfwn.bus.mipi_csi2.lane_polarities[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.csi2.lanecfg.clk.pol, + buscfg->bus.csi2.lanecfg.clk.pos); + +for (i =0 ; i <ISP_CSIPHY2_NUM_DATA_LANES ; i++) { + buscfg->bus.csi2.lanecfg.data[i].pos = + vfwn.bus.mipi_csi2.data_lanes[i]; + buscfg->bus.csi2.lanecfg.data[i].pol = + vfwn.bus.mipi_csi2.lane_polarities[i +1 ]; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, + buscfg->bus.csi2.lanecfg.data[i].pol, + buscfg->bus.csi2.lanecfg.data[i].pos); + } +/* +* FIXME: now we assume the CRC is always there. +* Implement a way to obtain this information from the +* sensor. Frame descriptors, perhaps? +*/ + + buscfg->bus.csi2.crc =1 ; } - -/* -* FIXME: now we assume the CRC is always there. -* Implement a way to obtain this information from the -* sensor. Frame descriptors, perhaps? -*/ - buscfg->bus.csi2.crc =1 ;break ;default :
drivers/media/platform/omap3isp/omap3isp.h +1 -0
@@ -108,6 +108,7 @@ struct isp_ccp2_cfg { unsigned int ccp2_mode:1; unsigned int phy_layer:1; unsigned int vpclk_div:2; + unsigned int vp_clk_pol:1;struct isp_csiphy_lanes_cfg lanecfg; };
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html