From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
"Carlos Sanmartín Bustos" <carsanbu@gmail.com>,
"Sylwester Nawrocki" <s.nawrocki@samsung.com>
Subject: Re: [PATCH v3 2/2] v4l: mt9v032: Add OF support
Date: Wed, 18 Mar 2015 15:32:28 +0200 [thread overview]
Message-ID: <2768138.CXiK86JdWh@avalon> (raw)
In-Reply-To: <20150315002107.GA11954@valkosipuli.retiisi.org.uk>
Hi Sakari,
On Sunday 15 March 2015 02:21:07 Sakari Ailus wrote:
> On Sat, Mar 14, 2015 at 04:57:37PM +0200, Laurent Pinchart wrote:
> ...
>
> > diff --git a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
> > b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt new file mode
> > 100644
> > index 0000000..68b134e
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
> > @@ -0,0 +1,45 @@
> > +* Aptina 1/3-Inch WVGA CMOS Digital Image Sensor
> > +
> > +The Aptina MT9V032 is a 1/3-inch CMOS active pixel digital image sensor
> > with +an active array size of 752H x 480V. It is programmable through a
> > simple +two-wire serial interface.
> > +
> > +Required Properties:
> > +
> > +- compatible: value should be either one among the following
> > + (a) "aptina,mt9v022" for MT9V022 color sensor
> > + (b) "aptina,mt9v022m" for MT9V022 monochrome sensor
> > + (c) "aptina,mt9v024" for MT9V024 color sensor
> > + (d) "aptina,mt9v024m" for MT9V024 monochrome sensor
> > + (e) "aptina,mt9v032" for MT9V032 color sensor
> > + (f) "aptina,mt9v032m" for MT9V032 monochrome sensor
> > + (g) "aptina,mt9v034" for MT9V034 color sensor
> > + (h) "aptina,mt9v034m" for MT9V034 monochrome sensor
> > +
> > +Optional Properties:
> > +
> > +- link-frequencies: List of allowed link frequencies in Hz. Each
> > frequency is + expressed as a 64-bit big-endian integer.
> > +
> > +For further reading on port node refer to
> > +Documentation/devicetree/bindings/media/video-interfaces.txt.
> > +
> > +Example:
> > +
> > + i2c0@1c22000 {
> > + ...
> > + ...
> > + mt9v032@5c {
> > + compatible = "aptina,mt9v032";
> > + reg = <0x5c>;
> > +
> > + port {
> > + mt9v032_1: endpoint {
> > + link-frequencies =
> > + <0 13000000>, <0 26600000>,
>
> How about:
>
> /bits/ 64 <13000000> ...
Absolutely.
> > + <0 27000000>;
> > + };
> > + };
> > + };
> > + ...
> > + };
> > diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
> > index 255ea91..139eeef 100644
> > --- a/drivers/media/i2c/mt9v032.c
> > +++ b/drivers/media/i2c/mt9v032.c
[snip]
> > @@ -876,10 +879,59 @@ static const struct regmap_config
> > mt9v032_regmap_config = {>
> > * Driver initialization and probing
> > */
> >
> > +static struct mt9v032_platform_data *
> > +mt9v032_get_pdata(struct i2c_client *client)
> > +{
> > + struct mt9v032_platform_data *pdata;
> > + struct v4l2_of_endpoint endpoint;
> > + struct device_node *np;
> > + struct property *prop;
> > +
> > + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
> > + return client->dev.platform_data;
> > +
> > + np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
> > + if (!np)
> > + return NULL;
> > +
> > + if (v4l2_of_parse_endpoint(np, &endpoint) < 0)
> > + goto done;
> > +
> > + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
> > + if (!pdata)
> > + goto done;
> > +
> > + prop = of_find_property(np, "link-frequencies", NULL);
> > + if (prop) {
> > + size_t size = prop->length / 8;
> > + u64 *link_freqs;
> > +
> > + link_freqs = devm_kzalloc(&client->dev,
> > + size * sizeof(*link_freqs),
>
> You could simply use prop->length here. I think that'd look nicer.
How about devm_kcalloc(&client->dev, size, sizeof(*link_freqs)) as this is
allocating an array ?
> > + GFP_KERNEL);
> > + if (!link_freqs)
> > + goto done;
> > +
> > + if (of_property_read_u64_array(np, "link-frequencies",
> > + link_freqs, size) < 0)
> > + goto done;
> > +
> > + pdata->link_freqs = link_freqs;
> > + pdata->link_def_freq = link_freqs[0];
> > + }
> > +
> > + pdata->clk_pol = !!(endpoint.bus.parallel.flags &
> > + V4L2_MBUS_PCLK_SAMPLE_RISING);
> > +
> > +done:
> > + of_node_put(np);
> > + return pdata;
> > +}
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2015-03-18 13:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-14 14:57 [PATCH v3 1/2] of: Add vendor prefix for Aptina Imaging Laurent Pinchart
2015-03-14 14:57 ` [PATCH v3 2/2] v4l: mt9v032: Add OF support Laurent Pinchart
[not found] ` <1426345057-2752-2-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2015-03-15 0:21 ` Sakari Ailus
2015-03-18 13:32 ` Laurent Pinchart [this message]
2015-03-18 20:56 ` Sakari Ailus
[not found] ` <1426345057-2752-1-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2015-03-18 13:40 ` [PATCH v3 1/2] of: Add vendor prefix for Aptina Imaging Laurent Pinchart
2015-03-18 15:59 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2768138.CXiK86JdWh@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=carsanbu@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=sakari.ailus@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).