From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: Arun Kumar K <arunkk.samsung@gmail.com>,
Sakari Ailus <sakari.ailus@iki.fi>
Cc: LMML <linux-media@vger.kernel.org>,
linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Stephen Warren <swarren@wwwdotorg.org>,
Mark Rutland <mark.rutland@arm.com>,
Pawel Moll <Pawel.Moll@arm.com>,
Kumar Gala <galak@codeaurora.org>,
Andrzej Hajda <a.hajda@samsung.com>,
Sachin Kamat <sachin.kamat@linaro.org>,
Shaik Ameer Basha <shaik.ameer@samsung.com>,
"kilyeon.im@samsung.com" <kilyeon.im@samsung.com>
Subject: Re: [PATCH v11 03/12] [media] exynos5-fimc-is: Add common driver header files
Date: Wed, 06 Nov 2013 12:23:07 +0100 [thread overview]
Message-ID: <527A269B.5040007@samsung.com> (raw)
In-Reply-To: <CALt3h7_BCj7yJi6sy=KVOHoET4aWm_a-N=u63R8-bZ-uQ=AGag@mail.gmail.com>
Hi,
On 05/11/13 14:16, Arun Kumar K wrote:
>>> +struct is_common_reg {
>>> + u32 hicmd;
>>> + u32 hic_sensorid;
>>> + u32 hic_param[4];
>>> +
>>> + u32 reserved1[3];
[...]
>>> + u32 meta_iflag;
>>> + u32 meta_sensor_id;
>>> + u32 meta_param1;
>>> +
>>> + u32 reserved9[1];
>>> +
>>> + u32 fcount;
>>
>> If these structs define an interface that's not used by the driver only it
>> might be a good idea to use __packed to ensure no padding is added.
>>
>
> The same structure is used as is in the firmware code and so it is retained
> in the driver.
I agree it makes sense to use __packed attribute to ensure no padding is
added by the compiler. The firmware source and the driver will likely be
compiled with different toolchains, and in both cases we should ensure
no padding is added.
>>> diff --git a/drivers/media/platform/exynos5-is/fimc-is-metadata.h b/drivers/media/platform/exynos5-is/fimc-is-metadata.h
>>> new file mode 100644
>>> index 0000000..02367c4
>>> --- /dev/null
>>> +++ b/drivers/media/platform/exynos5-is/fimc-is-metadata.h
>>> @@ -0,0 +1,767 @@
[..]
>>> +enum metadata_mode {
>>> + METADATA_MODE_NONE,
>>> + METADATA_MODE_FULL
>>> +};
>>> +
>>> +struct camera2_request_ctl {
>>> + uint32_t id;
>>> + enum metadata_mode metadatamode;
>>> + uint8_t outputstreams[16];
>>> + uint32_t framecount;
>>> +};
>>> +
>>> +struct camera2_request_dm {
>>> + uint32_t id;
>>> + enum metadata_mode metadatamode;
>>> + uint32_t framecount;
>>> +};
[...]
>>> +struct camera2_lens_ctl {
>>> + uint32_t focus_distance;
>>> + float aperture;
>>
>> Floating point numbers? Really? :-)
>>
>
> Yes as mentioned, the same structure is used by the firmware and
> so it is used as is in the kernel.
These floating numbers are pretty painful, but I don't think they can
be avoided unless the firmware is changed. I hope there is no need to
touch those in the kernel.
There are already precedents of using floating point numbers in driver's
public interface, e.g. some gpu/drm drivers.
I noticed there is another issue in this firmware/kernel interface, i.e.
some data structures contain enums in them, e.g.
struct camera2_lens_ctl {
uint32_t focus_distance;
float aperture;
float focal_length;
float filter_density;
enum optical_stabilization_mode optical_stabilization_mode;
};
It looks like a mistake in the interface design, as size of an enum is
implementation specific.
I guess size of those enum types is supposed to be 4 bytes ? Presumably
you should, e.g. use fixed data type like uin32_t or __u32 instead of those
enums. It looks pretty fragile as it is now.
In addition all those data structures should be declared with __packed
attribute, to ensure a specific data structure layout and to avoid
an unexpected padding.
>> diff --git a/drivers/media/platform/exynos5-is/fimc-is-param.h b/drivers/media/platform/exynos5-is/fimc-is-param.h
>> new file mode 100644
>> index 0000000..015cc13
>> --- /dev/null
>> +++ b/drivers/media/platform/exynos5-is/fimc-is-param.h
> ...
>> +struct param_control {
>> + u32 cmd;
>
> You use uint32_t in some other headers. It's not wrong to use both C99 and
> Linux types but I'd try to stick to either one.
I tend to agree with that, it's probably better to use one convention, u32
for kernel internal structures and __u32 for any public interfaces. I don't
think it is e requirement but would be nice to keep it more consistent.
Even if we wanted to keep the firmware defined data structures in sync with
the Linux driver, there are already some Linux types used within the firmware
interface. if I understood things correctly.
>> + u32 bypass;
>> + u32 buffer_address;
>> + u32 buffer_number;
>> + /* 0: continuous, 1: single */
>> + u32 run_mode;
>> + u32 reserved[PARAMETER_MAX_MEMBER - 6];
>> + u32 err;
>> +};
Can you please address those issues in follow up patches ?
I will be sending these patches for inclusion in the media tree,
I would prefer to avoid keeping it on the ML for more than those
7 months already passed.
--
Regards,
Sylwester
next prev parent reply other threads:[~2013-11-06 11:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 6:12 [PATCH v11 00/12] Exynos5 IS driver Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 01/12] [media] exynos5-fimc-is: Add Exynos5 FIMC-IS device tree bindings documentation Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 02/12] [media] exynos5-fimc-is: Add driver core files Arun Kumar K
2013-11-05 11:21 ` Sakari Ailus
2013-11-05 11:30 ` Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 03/12] [media] exynos5-fimc-is: Add common driver header files Arun Kumar K
2013-11-05 12:51 ` Sakari Ailus
2013-11-05 13:16 ` Arun Kumar K
2013-11-06 11:23 ` Sylwester Nawrocki [this message]
2013-11-06 11:51 ` Arun Kumar K
2013-11-06 13:01 ` Sakari Ailus
2013-11-05 6:12 ` [PATCH v11 04/12] [media] exynos5-fimc-is: Add register definition and context header Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 05/12] [media] exynos5-fimc-is: Add isp subdev Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 06/12] [media] exynos5-fimc-is: Add scaler subdev Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 07/12] [media] exynos5-fimc-is: Add sensor interface Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 08/12] [media] exynos5-fimc-is: Add the hardware pipeline control Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 09/12] [media] exynos5-fimc-is: Add the hardware interface module Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 10/12] [media] exynos5-is: Add Kconfig and Makefile Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 11/12] V4L: Add DT binding doc for s5k4e5 image sensor Arun Kumar K
2013-11-05 6:12 ` [PATCH v11 12/12] V4L: Add s5k4e5 sensor driver Arun Kumar K
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=527A269B.5040007@samsung.com \
--to=s.nawrocki@samsung.com \
--cc=Pawel.Moll@arm.com \
--cc=a.hajda@samsung.com \
--cc=arunkk.samsung@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=hverkuil@xs4all.nl \
--cc=kilyeon.im@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=sachin.kamat@linaro.org \
--cc=sakari.ailus@iki.fi \
--cc=shaik.ameer@samsung.com \
--cc=swarren@wwwdotorg.org \
/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