Re: [RFC/PATCH v6 02/12] media: Media device

2010-11-25 Thread Clemens Ladisch
Laurent Pinchart wrote:
 +struct media_device {
 ...
 + u8 model[32];
 + u8 serial[40];
 + u8 bus_info[32];

All drivers and userspace applications have to treat this as char[], so
why u8[]?


Regards,
Clemens
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH v6 02/12] media: Media device

2010-11-25 Thread Laurent Pinchart
Hi Clemens,

Thanks for the review.

On Thursday 25 November 2010 10:33:02 Clemens Ladisch wrote:
 Laurent Pinchart wrote:
  +struct media_device {
  ...
  +   u8 model[32];
  +   u8 serial[40];
  +   u8 bus_info[32];
 
 All drivers and userspace applications have to treat this as char[], so
 why u8[]?

Good question. I've copied the V4L2 practice of using u8 (or __u8) for fixed-
length strings in structures. I can't think of any reason for that.

I will replace u8 with char unless someone comes up with a good reason to keep 
u8.

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH v6 02/12] media: Media device

2010-11-25 Thread Andy Walls
The signedness of char is ambiguous for 8 bit data, which is why an API would 
normally use u8 (or s8, I guess).

Since this is known to be character data, I would think char would be fine.  I 
am assuming C compilers would never assume multibyte chars.

Regards,
Andy

Laurent Pinchart laurent.pinch...@ideasonboard.com wrote:

Hi Clemens,

Thanks for the review.

On Thursday 25 November 2010 10:33:02 Clemens Ladisch wrote:
 Laurent Pinchart wrote:
  +struct media_device {
  ...
  +  u8 model[32];
  +  u8 serial[40];
  +  u8 bus_info[32];
 
 All drivers and userspace applications have to treat this as char[], so
 why u8[]?

Good question. I've copied the V4L2 practice of using u8 (or __u8) for fixed-
length strings in structures. I can't think of any reason for that.

I will replace u8 with char unless someone comes up with a good reason to keep 
u8.

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
N�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ�)ߡ�a�����G���h��j:+v���w��٥

Re: [RFC/PATCH v6 02/12] media: Media device

2010-11-25 Thread Alan Cox
On Thu, 25 Nov 2010 12:20:31 -0500
Andy Walls awa...@md.metrocast.net wrote:

 The signedness of char is ambiguous for 8 bit data, which is why an API would 
 normally use u8 (or s8, I guess).
 
 Since this is known to be character data, I would think char would be fine.  
 I am assuming C compilers would never assume multibyte chars.

char is 8bit in all modern C. I have used C compilers with configurable 9
or 7 bit char and such a machine is never going to run Linux without
serious insanity. Even grep in 9bit char is not fun...

The advantage of using u8 is that any casting goes the way you expect
whereas when working with UTF-8 things like

int x = name[0];

may not produce the expected result otherwise.

Alan
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH v6 02/12] media: Media device

2010-11-24 Thread Laurent Pinchart
The media_device structure abstracts functions common to all kind of
media devices (v4l2, dvb, alsa, ...). It manages media entities and
offers a userspace API to discover and configure the media device
internal topology.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media-entities.tmpl  |2 +
 Documentation/DocBook/media.tmpl   |3 +
 Documentation/DocBook/v4l/media-controller.xml |   56 +
 Documentation/media-framework.txt  |   68 
 drivers/media/Makefile |2 +-
 drivers/media/media-device.c   |  100 
 include/media/media-device.h   |   66 
 7 files changed, 296 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/DocBook/v4l/media-controller.xml
 create mode 100644 Documentation/media-framework.txt
 create mode 100644 drivers/media/media-device.c
 create mode 100644 include/media/media-device.h

diff --git a/Documentation/DocBook/media-entities.tmpl 
b/Documentation/DocBook/media-entities.tmpl
index be34dcb..61d6f11 100644
--- a/Documentation/DocBook/media-entities.tmpl
+++ b/Documentation/DocBook/media-entities.tmpl
@@ -321,6 +321,8 @@
 !ENTITY sub-media-entities SYSTEM media-entities.tmpl
 !ENTITY sub-media-indices SYSTEM media-indices.tmpl
 
+!ENTITY sub-media-controller SYSTEM v4l/media-controller.xml
+
 !-- Function Reference --
 !ENTITY close SYSTEM v4l/func-close.xml
 !ENTITY ioctl SYSTEM v4l/func-ioctl.xml
diff --git a/Documentation/DocBook/media.tmpl b/Documentation/DocBook/media.tmpl
index f11048d..73464b0 100644
--- a/Documentation/DocBook/media.tmpl
+++ b/Documentation/DocBook/media.tmpl
@@ -106,6 +106,9 @@ Foundation. A copy of the license is included in the 
chapter entitled
 sub-remote_controllers;
 /chapter
 /part
+part id=media_common
+sub-media-controller;
+/part
 
 sub-fdl-appendix;
 
diff --git a/Documentation/DocBook/v4l/media-controller.xml 
b/Documentation/DocBook/v4l/media-controller.xml
new file mode 100644
index 000..253ddb4
--- /dev/null
+++ b/Documentation/DocBook/v4l/media-controller.xml
@@ -0,0 +1,56 @@
+partinfo
+  authorgroup
+author
+  firstnameLaurent/firstname
+  surnamePinchart/surname
+  
affiliationaddressemaillaurent.pinch...@ideasonboard.com/email/address/affiliation
+  contribInitial version./contrib
+/author
+  /authorgroup
+  copyright
+year2010/year
+holderLaurent Pinchart/holder
+  /copyright
+
+  revhistory
+!-- Put document revisions here, newest first. --
+revision
+  revnumber1.0.0/revnumber
+  date2010-11-10/date
+  authorinitialslp/authorinitials
+  revremarkInitial revision/revremark
+/revision
+  /revhistory
+/partinfo
+
+titleMedia Controller API/title
+
+chapter id=media_controller
+  titleMedia Controller/title
+
+  section id=media-controller-intro
+titleIntroduction/title
+paraMedia devices increasingly handle multiple related functions. Many 
USB
+cameras include microphones, video capture hardware can also output video,
+or SoC camera interfaces also perform memory-to-memory operations similar 
to
+video codecs./para
+paraIndependent functions, even when implemented in the same hardware, 
can
+be modelled as separate devices. A USB camera with a microphone will be
+presented to userspace applications as V4L2 and ALSA capture devices. The
+devices' relationships (when using a webcam, end-users shouldn't have to
+manually select the associated USB microphone), while not made available
+directly to applications by the drivers, can usually be retrieved from
+sysfs./para
+paraWith more and more advanced SoC devices being introduced, the current
+approach will not scale. Device topologies are getting increasingly complex
+and can't always be represented by a tree structure. Hardware blocks are
+shared between different functions, creating dependencies between seemingly
+unrelated devices./para
+paraKernel abstraction APIs such as V4L2 and ALSA provide means for
+applications to access hardware parameters. As newer hardware expose an
+increasingly high number of those parameters, drivers need to guess what
+applications really require based on limited information, thereby
+implementing policies that belong to userspace./para
+paraThe media controller API aims at solving those problems./para
+  /section
+/chapter
diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
new file mode 100644
index 000..84fa43a
--- /dev/null
+++ b/Documentation/media-framework.txt
@@ -0,0 +1,68 @@
+Linux kernel media framework
+
+
+This document describes the Linux kernel media framework, its data structures,
+functions and their usage.
+
+
+Introduction
+
+
+The media controller API is documented in DocBook format in