[PATCH 15/15] staging: media: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h

2014-11-04 Thread Boris Brezillon
The v4l2-mediabus.h header is now deprecated and should be replaced with
v4l2-mbus.h.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/staging/media/omap4iss/iss_csi2.c  | 2 +-
 drivers/staging/media/omap4iss/iss_video.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss_csi2.c 
b/drivers/staging/media/omap4iss/iss_csi2.c
index b72e530..f47e4e5 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -13,7 +13,7 @@
 
 #include linux/delay.h
 #include media/v4l2-common.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/mm.h
 
 #include iss.h
diff --git a/drivers/staging/media/omap4iss/iss_video.h 
b/drivers/staging/media/omap4iss/iss_video.h
index cc8146b..a028b51 100644
--- a/drivers/staging/media/omap4iss/iss_video.h
+++ b/drivers/staging/media/omap4iss/iss_video.h
@@ -14,7 +14,7 @@
 #ifndef OMAP4_ISS_VIDEO_H
 #define OMAP4_ISS_VIDEO_H
 
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include media/media-entity.h
 #include media/v4l2-dev.h
 #include media/v4l2-fh.h
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/15] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-04 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/uapi/linux/v4l2-mediabus.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 9fbe891..5a3e797 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,6 +15,7 @@
 #include linux/videodev2.h
 #include linux/media-bus-format.h
 
+#ifndef __KERNEL__
 #define MEDIA_BUS_TO_V4L2_MBUS(x)  V4L2_MBUS_FMT_ ## x = MEDIA_BUS_FMT_ ## 
x
 
 enum v4l2_mbus_pixelcode {
@@ -102,6 +103,7 @@ enum v4l2_mbus_pixelcode {
 
MEDIA_BUS_TO_V4L2_MBUS(AHSV_1X32),
 };
+#endif /* __KERNEL__ */
 
 /**
  * struct v4l2_mbus_framefmt - frame format on the media bus
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/15] gpu: ipu-v3: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h

2014-11-04 Thread Boris Brezillon
The v4l2-mediabus.h header is now deprecated and should be replaced with
v4l2-mbus.h.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index 752cdd2..8aea0de 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -21,7 +21,7 @@
 #include linux/err.h
 #include linux/platform_device.h
 #include linux/videodev2.h
-#include uapi/linux/v4l2-mediabus.h
+#include uapi/linux/v4l2-mbus.h
 #include linux/clk.h
 #include linux/clk-provider.h
 #include linux/clkdev.h
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/15] [media] Deprecate v4l2_mbus_pixelcode

2014-11-04 Thread Boris Brezillon
The v4l2_mbus_pixelcode enum (or its values) should be replaced by the
media_bus_format enum.
Keep this enum in v4l2-mediabus.h and create a new header containing
the v4l2_mbus_framefmt struct definition (which is not deprecated) so
that we can add a #warning statement in v4l2-mediabus.h and hopefully
encourage users to move to the new definitions.

Replace inclusion of v4l2-mediabus.h with v4l2-mbus.h in all common headers
and update the documentation Makefile to parse v4l2-mbus.h instead of
v4l2-mediabus.h.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/DocBook/media/Makefile |  2 +-
 include/media/v4l2-mediabus.h|  2 +-
 include/uapi/linux/Kbuild|  1 +
 include/uapi/linux/v4l2-mbus.h   | 35 +++
 include/uapi/linux/v4l2-mediabus.h   | 26 --
 include/uapi/linux/v4l2-subdev.h |  2 +-
 6 files changed, 43 insertions(+), 25 deletions(-)
 create mode 100644 include/uapi/linux/v4l2-mbus.h

diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 181b7f4..30a22fa 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -99,7 +99,7 @@ STRUCTS = \
$(shell perl -ne 'print $$1  if (/^struct\s+([^\s]+)\s+/)' 
$(srctree)/include/uapi/linux/dvb/video.h) \
$(shell perl -ne 'print $$1  if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media.h) \
$(shell perl -ne 'print $$1  if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-subdev.h) \
-   $(shell perl -ne 'print $$1  if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-mediabus.h)
+   $(shell perl -ne 'print $$1  if /^struct\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-mbus.h)
 
 ERRORS = \
E2BIG \
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 4915621..fc6bdd3 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -11,7 +11,7 @@
 #ifndef V4L2_MEDIABUS_H
 #define V4L2_MEDIABUS_H
 
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 
 /* Parallel flags */
 /*
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b2c23f8..7b72720 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -408,6 +408,7 @@ header-y += uvcvideo.h
 header-y += v4l2-common.h
 header-y += v4l2-controls.h
 header-y += v4l2-dv-timings.h
+header-y += v4l2-mbus.h
 header-y += v4l2-mediabus.h
 header-y += v4l2-subdev.h
 header-y += veth.h
diff --git a/include/uapi/linux/v4l2-mbus.h b/include/uapi/linux/v4l2-mbus.h
new file mode 100644
index 000..2778c6e
--- /dev/null
+++ b/include/uapi/linux/v4l2-mbus.h
@@ -0,0 +1,35 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_V4L2_MBUS_H
+#define __LINUX_V4L2_MBUS_H
+
+#include linux/types.h
+#include linux/videodev2.h
+#include linux/media-bus-format.h
+
+/**
+ * struct v4l2_mbus_framefmt - frame format on the media bus
+ * @width: frame width
+ * @height:frame height
+ * @code:  data format code (from enum media_bus_format)
+ * @field: used interlacing type (from enum v4l2_field)
+ * @colorspace:colorspace of the data (from enum v4l2_colorspace)
+ */
+struct v4l2_mbus_framefmt {
+   __u32   width;
+   __u32   height;
+   __u32   code;
+   __u32   field;
+   __u32   colorspace;
+   __u32   reserved[7];
+};
+
+#endif
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 5a3e797..a587eac 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -10,12 +10,12 @@
 
 #ifndef __LINUX_V4L2_MEDIABUS_H
 #define __LINUX_V4L2_MEDIABUS_H
+#ifndef __KERNEL__
 
-#include linux/types.h
-#include linux/videodev2.h
-#include linux/media-bus-format.h
+#warning Use v4l2-mbus.h instead of v4l2-mediabus.h
+
+#include linux/v4l2-mbus.h
 
-#ifndef __KERNEL__
 #define MEDIA_BUS_TO_V4L2_MBUS(x)  V4L2_MBUS_FMT_ ## x = MEDIA_BUS_FMT_ ## 
x
 
 enum v4l2_mbus_pixelcode {
@@ -104,22 +104,4 @@ enum v4l2_mbus_pixelcode {
MEDIA_BUS_TO_V4L2_MBUS(AHSV_1X32),
 };
 #endif /* __KERNEL__ */
-
-/**
- * struct v4l2_mbus_framefmt - frame format on the media bus
- * @width: frame width
- * @height:frame height
- * @code:  data format code (from enum v4l2_mbus_pixelcode)
- * @field: used interlacing type (from enum v4l2_field)
- * @colorspace:colorspace of the data (from enum v4l2_colorspace)
- */
-struct v4l2_mbus_framefmt {
-   __u32   width;
-   __u32

[PATCH 03/15] [media] Make use of the new media_bus_format definitions

2014-11-04 Thread Boris Brezillon
Replace references to the v4l2_mbus_pixelcode enum with the new
media_bus_format enum in all common headers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/media/v4l2-mediabus.h| 2 +-
 include/media/v4l2-subdev.h  | 2 +-
 include/uapi/linux/v4l2-subdev.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 395c4a9..4915621 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -98,7 +98,7 @@ static inline void v4l2_fill_pix_format(struct 
v4l2_pix_format *pix_fmt,
 
 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
   const struct v4l2_pix_format *pix_fmt,
-  enum v4l2_mbus_pixelcode code)
+  enum media_bus_format code)
 {
mbus_fmt-width = pix_fmt-width;
mbus_fmt-height = pix_fmt-height;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d746572..9af5932 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -341,7 +341,7 @@ struct v4l2_subdev_video_ops {
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
-enum v4l2_mbus_pixelcode *code);
+enum media_bus_format *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a619cdd..7f44f04 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -68,7 +68,7 @@ struct v4l2_subdev_crop {
  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  */
 struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -81,7 +81,7 @@ struct v4l2_subdev_mbus_code_enum {
  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  */
 struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -109,7 +109,7 @@ struct v4l2_subdev_frame_interval {
  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
  * @pad: pad number, as reported by the media API
  * @index: frame interval index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/15] [media] Make mediabus format subsystem neutral

2014-11-04 Thread Boris Brezillon
Hello,

This patch series prepares the use of media bus formats outside of
the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
driver where I have to configure my DPI/RGB bus according to the
connected display).

The series first defines a new enum with a neutral name (media_bus_format),
and then replace all references to the old enum and its values within the
kernel.

It also deprecates the v4l2_mbus_pixelcode enum and the v4l2-mediabus.h
header. Kernel users can't use the v4l2_mbus_pixelcode enum anymore and new
user-space users are encouraged to move to the media_bus_format enum
and include v4l2-mbus.h.

Hans, I'm not sure this is exactly what you had in mind for
v4l2_mbus_pixelcode deprecation. If you agree with this approach, and think
it is worth it, I can reorder the series and squash the last 4 patches into
previous ones (patches 4, 9, 6 and 8)

Best Regards,

Boris

Boris Brezillon (15):
  [media] Move mediabus format definition to a more standard place
  [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values
  [media] Make use of the new media_bus_format definitions
  [media] i2c: Make use of media_bus_format enum
  [media] pci: Make use of media_bus_format enum
  [media] platform: Make use of media_bus_format enum
  [media] usb: Make use of media_bus_format enum
  staging: media: Make use of media_bus_format enum
  gpu: ipu-v3: Make use of media_bus_format enum
  [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the
kernel
  [media] Deprecate v4l2_mbus_pixelcode
  [media] i2c: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h
  gpu: ipu-v3: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h
  [media] platform: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h
  staging: media: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h

 Documentation/DocBook/media/Makefile   |   4 +-
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   6 +-
 arch/arm/mach-davinci/dm365.c  |   6 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |  68 ++---
 drivers/media/i2c/adv7170.c|  16 +-
 drivers/media/i2c/adv7175.c|  16 +-
 drivers/media/i2c/adv7180.c|   6 +-
 drivers/media/i2c/adv7183.c|   6 +-
 drivers/media/i2c/adv7604.c|  72 ++---
 drivers/media/i2c/adv7842.c|   6 +-
 drivers/media/i2c/ak881x.c |   8 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   6 +-
 drivers/media/i2c/ml86v7667.c  |   6 +-
 drivers/media/i2c/mt9m032.c|   8 +-
 drivers/media/i2c/mt9p031.c|   8 +-
 drivers/media/i2c/mt9t001.c|  10 +-
 drivers/media/i2c/mt9v011.c|   6 +-
 drivers/media/i2c/mt9v032.c|  14 +-
 drivers/media/i2c/noon010pc30.c|  12 +-
 drivers/media/i2c/ov7670.c |  16 +-
 drivers/media/i2c/ov9650.c |  10 +-
 drivers/media/i2c/s5c73m3/s5c73m3.h|   6 +-
 drivers/media/i2c/s5k4ecgx.c   |   4 +-
 drivers/media/i2c/s5k5baf.c|  14 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   8 +-
 drivers/media/i2c/saa6752hs.c  |   6 +-
 drivers/media/i2c/saa7115.c|   2 +-
 drivers/media/i2c/saa717x.c|   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  34 +--
 drivers/media/i2c/soc_camera/imx074.c  |  10 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  14 +-
 drivers/media/i2c/soc_camera/mt9m111.c |  72 ++---
 drivers/media/i2c/soc_camera/mt9t031.c |  12 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  24 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  26 +-
 drivers/media/i2c/soc_camera/ov2640.c  |  56 ++--
 drivers/media/i2c/soc_camera/ov5642.c  |  10 +-
 drivers/media/i2c/soc_camera/ov6650.c  |  60 ++--
 drivers/media/i2c/soc_camera/ov772x.c  |  22 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  42 +--
 drivers/media/i2c/soc_camera/ov9740.c  |  14 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  56 ++--
 drivers/media/i2c/soc_camera/tw9910.c  |  12 +-
 drivers/media/i2c/sr030pc30.c

[PATCH 14/15] [media] platform: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h

2014-11-04 Thread Boris Brezillon
The v4l2-mediabus.h header is now deprecated and should be replaced with
v4l2-mbus.h.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/platform/omap3isp/ispcsi2.c  | 2 +-
 drivers/media/platform/omap3isp/ispvideo.h | 2 +-
 drivers/media/platform/vsp1/vsp1_video.c   | 2 +-
 include/media/soc_mediabus.h   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispcsi2.c 
b/drivers/media/platform/omap3isp/ispcsi2.c
index 995a268..64acb66 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -15,7 +15,7 @@
  */
 #include linux/delay.h
 #include media/v4l2-common.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/mm.h
 
 #include isp.h
diff --git a/drivers/media/platform/omap3isp/ispvideo.h 
b/drivers/media/platform/omap3isp/ispvideo.h
index 9de3de5..7738d27 100644
--- a/drivers/media/platform/omap3isp/ispvideo.h
+++ b/drivers/media/platform/omap3isp/ispvideo.h
@@ -16,7 +16,7 @@
 #ifndef OMAP3_ISP_VIDEO_H
 #define OMAP3_ISP_VIDEO_H
 
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include media/media-entity.h
 #include media/v4l2-dev.h
 #include media/v4l2-fh.h
diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index d91f19a..bb3af00 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -16,7 +16,7 @@
 #include linux/mutex.h
 #include linux/sched.h
 #include linux/slab.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/videodev2.h
 
 #include media/media-entity.h
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h
index 9d8e7a1..e357182 100644
--- a/include/media/soc_mediabus.h
+++ b/include/media/soc_mediabus.h
@@ -12,7 +12,7 @@
 #define SOC_MEDIABUS_H
 
 #include linux/videodev2.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 
 /**
  * enum soc_mbus_packing - data packing types on the media-bus
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/15] [media] usb: Make use of media_bus_format enum

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all usb drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++--
 drivers/media/usb/em28xx/em28xx-camera.c  | 2 +-
 drivers/media/usb/go7007/go7007-v4l2.c| 2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 459bb0e..95653ba 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1878,7 +1878,7 @@ static int cx231xx_s_video_encoding(struct 
cx2341x_handler *cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev-sd_cx25840, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 3b3ada6..989d527 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -967,7 +967,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-height = f-fmt.pix.height;
dev-format = fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
 
@@ -1012,7 +1012,7 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id norm)
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
memset(mbus_fmt, 0, sizeof(mbus_fmt));
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = dev-width;
mbus_fmt.height = dev-height;
call_all(dev, video, s_mbus_fmt, mbus_fmt);
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index 6d2ea9a..38cf6c8 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -430,7 +430,7 @@ int em28xx_init_camera(struct em28xx *dev)
break;
}
 
-   fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
+   fmt.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640;
fmt.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, fmt);
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c 
b/drivers/media/usb/go7007/go7007-v4l2.c
index ec799b4..d6bf982 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct 
v4l2_format *fmt, int try)
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt;
 
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt-fmt.pix.width : width;
mbus_fmt.height = height;
go-encoder_h_halve = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 9623b62..2fd9b5e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
memset(fmt, 0, sizeof(fmt));
fmt.width = hdw-res_hor_val;
fmt.height = hdw-res_ver_val;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, subdev v4l2 set_size(%dx%d),
   fmt.width, fmt.height);
v4l2_device_call_all(hdw-v4l2_dev, 0, video, s_mbus_fmt, 
fmt);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/15] [media] pci: Make use of media_bus_format enum

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definition in pci drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/pci/cx18/cx18-av-core.c   | 2 +-
 drivers/media/pci/cx18/cx18-controls.c  | 2 +-
 drivers/media/pci/cx18/cx18-ioctl.c | 2 +-
 drivers/media/pci/cx23885/cx23885-video.c   | 2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c | 2 +-
 drivers/media/pci/saa7134/saa7134-empress.c | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-av-core.c 
b/drivers/media/pci/cx18/cx18-av-core.c
index 2d3afe0..4c6ce21 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, 
struct v4l2_mbus_framefmt
int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
int is_50Hz = !(state-std  V4L2_STD_525_60);
 
-   if (fmt-code != V4L2_MBUS_FMT_FIXED)
+   if (fmt-code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
 
fmt-field = V4L2_FIELD_INTERLACED;
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 282a3d2..4aeb7c6 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 6f2b590..71963db 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
 
mbus_fmt.width = cx-cxhdl.width = w;
mbus_fmt.height = cx-cxhdl.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, mbus_fmt);
return cx18_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f9..091f5db 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -608,7 +608,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-field  = f-fmt.pix.field;
dprintk(2, %s() width=%d height=%d field=%d\n, __func__,
dev-width, dev-height, dev-field);
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
/* s_mbus_fmt overwrites f-fmt.pix.field, restore it */
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 2b0ab26..ccf548c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3e0cb77..4d8ee18 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, 
struct v4l2_format *f
fmt-fmt.pix.width /= 2;
mbus_fmt.width = fmt-fmt.pix.width;
mbus_fmt.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, mbus_fmt);
return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c 
b/drivers/media/pci/saa7134/saa7134-empress.c
index e4ea85f..8b3bb78 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -140,7 +140,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void 
*priv,
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f

[PATCH 01/15] [media] Move mediabus format definition to a more standard place

2014-11-04 Thread Boris Brezillon
Rename mediabus formats and move the enum into a separate header file so
that it can be used by DRM/KMS subsystem without any reference to the V4L2
subsystem.

Old V4L2_MBUS_FMT_ definitions are now referencing MEDIA_BUS_FMT_ value.

Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/media-bus-format.h | 126 +++
 include/uapi/linux/v4l2-mediabus.h| 184 +++---
 3 files changed, 206 insertions(+), 105 deletions(-)
 create mode 100644 include/uapi/linux/media-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e..b2c23f8 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -414,6 +414,7 @@ header-y += veth.h
 header-y += vfio.h
 header-y += vhost.h
 header-y += videodev2.h
+header-y += media-bus-format.h
 header-y += virtio_9p.h
 header-y += virtio_balloon.h
 header-y += virtio_blk.h
diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
new file mode 100644
index 000..2a826e9
--- /dev/null
+++ b/include/uapi/linux/media-bus-format.h
@@ -0,0 +1,126 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MEDIA_BUS_FORMAT_H
+#define __LINUX_MEDIA_BUS_FORMAT_H
+
+/*
+ * These bus formats uniquely identify data formats on the data bus. Format 0
+ * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where
+ * the data format is fixed. Additionally, 2X8 means that one pixel is
+ * transferred in two 8-bit samples, BE or LE specify in which order those
+ * samples are transferred over the bus: LE means that the least significant
+ * bits are transferred first, BE means that the most significant bits are
+ * transferred first, and PADHI and PADLO define which bits - low or high,
+ * in the incomplete high byte, are filled with padding bits.
+ *
+ * The bus formats are grouped by type, bus_width, bits per component, samples
+ * per pixel and order of subsamples. Numerical values are sorted using generic
+ * numerical sort order (8 thus comes before 10).
+ *
+ * As their value can't change when a new bus format is inserted in the
+ * enumeration, the bus formats are explicitly given a numerical value. The 
next
+ * free values for each category are listed below, update them when inserting
+ * new pixel codes.
+ */
+enum media_bus_format {
+   MEDIA_BUS_FMT_FIXED = 0x0001,
+
+   /* RGB - next is 0x100e */
+   MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
+   MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
+   MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
+   MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE = 0x1004,
+   MEDIA_BUS_FMT_BGR565_2X8_BE = 0x1005,
+   MEDIA_BUS_FMT_BGR565_2X8_LE = 0x1006,
+   MEDIA_BUS_FMT_RGB565_2X8_BE = 0x1007,
+   MEDIA_BUS_FMT_RGB565_2X8_LE = 0x1008,
+   MEDIA_BUS_FMT_RGB666_1X18 = 0x1009,
+   MEDIA_BUS_FMT_RGB888_1X24 = 0x100a,
+   MEDIA_BUS_FMT_RGB888_2X12_BE = 0x100b,
+   MEDIA_BUS_FMT_RGB888_2X12_LE = 0x100c,
+   MEDIA_BUS_FMT_ARGB_1X32 = 0x100d,
+
+   /* YUV (including grey) - next is 0x2024 */
+   MEDIA_BUS_FMT_Y8_1X8 = 0x2001,
+   MEDIA_BUS_FMT_UV8_1X8 = 0x2015,
+   MEDIA_BUS_FMT_UYVY8_1_5X8 = 0x2002,
+   MEDIA_BUS_FMT_VYUY8_1_5X8 = 0x2003,
+   MEDIA_BUS_FMT_YUYV8_1_5X8 = 0x2004,
+   MEDIA_BUS_FMT_YVYU8_1_5X8 = 0x2005,
+   MEDIA_BUS_FMT_UYVY8_2X8 = 0x2006,
+   MEDIA_BUS_FMT_VYUY8_2X8 = 0x2007,
+   MEDIA_BUS_FMT_YUYV8_2X8 = 0x2008,
+   MEDIA_BUS_FMT_YVYU8_2X8 = 0x2009,
+   MEDIA_BUS_FMT_Y10_1X10 = 0x200a,
+   MEDIA_BUS_FMT_UYVY10_2X10 = 0x2018,
+   MEDIA_BUS_FMT_VYUY10_2X10 = 0x2019,
+   MEDIA_BUS_FMT_YUYV10_2X10 = 0x200b,
+   MEDIA_BUS_FMT_YVYU10_2X10 = 0x200c,
+   MEDIA_BUS_FMT_Y12_1X12 = 0x2013,
+   MEDIA_BUS_FMT_UYVY8_1X16 = 0x200f,
+   MEDIA_BUS_FMT_VYUY8_1X16 = 0x2010,
+   MEDIA_BUS_FMT_YUYV8_1X16 = 0x2011,
+   MEDIA_BUS_FMT_YVYU8_1X16 = 0x2012,
+   MEDIA_BUS_FMT_YDYUYDYV8_1X16 = 0x2014,
+   MEDIA_BUS_FMT_UYVY10_1X20 = 0x201a,
+   MEDIA_BUS_FMT_VYUY10_1X20 = 0x201b,
+   MEDIA_BUS_FMT_YUYV10_1X20 = 0x200d,
+   MEDIA_BUS_FMT_YVYU10_1X20 = 0x200e,
+   MEDIA_BUS_FMT_YUV10_1X30 = 0x2016,
+   MEDIA_BUS_FMT_AYUV8_1X32 = 0x2017,
+   MEDIA_BUS_FMT_UYVY12_2X12 = 0x201c,
+   MEDIA_BUS_FMT_VYUY12_2X12 = 0x201d,
+   MEDIA_BUS_FMT_YUYV12_2X12 = 0x201e,
+   MEDIA_BUS_FMT_YVYU12_2X12 = 0x201f,
+   MEDIA_BUS_FMT_UYVY12_1X24 = 0x2020,
+   MEDIA_BUS_FMT_VYUY12_1X24 = 0x2021,
+   MEDIA_BUS_FMT_YUYV12_1X24 = 0x2022,
+   MEDIA_BUS_FMT_YVYU12_1X24

[PATCH 09/15] gpu: ipu-v3: Make use of media_bus_format enum

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in the ipu-v3 driver.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 66 ++--
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index d6f56471..752cdd2 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -227,83 +227,83 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, 
u32 pixel_clk,
 static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 {
switch (mbus_code) {
-   case V4L2_MBUS_FMT_BGR565_2X8_BE:
-   case V4L2_MBUS_FMT_BGR565_2X8_LE:
-   case V4L2_MBUS_FMT_RGB565_2X8_BE:
-   case V4L2_MBUS_FMT_RGB565_2X8_LE:
+   case MEDIA_BUS_FMT_BGR565_2X8_BE:
+   case MEDIA_BUS_FMT_BGR565_2X8_LE:
+   case MEDIA_BUS_FMT_RGB565_2X8_BE:
+   case MEDIA_BUS_FMT_RGB565_2X8_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
cfg-mipi_dt = MIPI_DT_RGB565;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB444;
cfg-mipi_dt = MIPI_DT_RGB444;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB555;
cfg-mipi_dt = MIPI_DT_RGB555;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_YUYV8_2X8:
+   case MEDIA_BUS_FMT_YUYV8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_YUYV8_1X16:
+   case MEDIA_BUS_FMT_YUYV8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_SBGGR8_1X8:
-   case V4L2_MBUS_FMT_SGBRG8_1X8:
-   case V4L2_MBUS_FMT_SGRBG8_1X8:
-   case V4L2_MBUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW8;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+   case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW10;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_1X10:
-   case V4L2_MBUS_FMT_SGBRG10_1X10:
-   case V4L2_MBUS_FMT_SGRBG10_1X10:
-   case V4L2_MBUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
cfg-data_fmt

[PATCH 12/15] [media] i2c: Replace v4l2-mediabus.h inclusion with v4l2-mbus.h

2014-11-04 Thread Boris Brezillon
The v4l2-mediabus.h header is now deprecated and should be replaced with
v4l2-mbus.h.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/i2c/mt9m032.c   | 2 +-
 drivers/media/i2c/mt9t001.c   | 2 +-
 drivers/media/i2c/mt9v032.c   | 2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 2 +-
 drivers/media/i2c/soc_camera/imx074.c | 2 +-
 drivers/media/i2c/soc_camera/mt9m111.c| 2 +-
 drivers/media/i2c/soc_camera/mt9t031.c| 2 +-
 drivers/media/i2c/soc_camera/mt9t112.c| 2 +-
 drivers/media/i2c/soc_camera/ov2640.c | 2 +-
 drivers/media/i2c/soc_camera/ov5642.c | 2 +-
 drivers/media/i2c/soc_camera/ov6650.c | 2 +-
 drivers/media/i2c/soc_camera/ov772x.c | 2 +-
 drivers/media/i2c/soc_camera/ov9640.c | 2 +-
 drivers/media/i2c/soc_camera/ov9740.c | 2 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 2 +-
 drivers/media/i2c/soc_camera/tw9910.c | 2 +-
 drivers/media/i2c/tvp514x.c   | 2 +-
 17 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 45b3fca..502b23f 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -28,7 +28,7 @@
 #include linux/module.h
 #include linux/mutex.h
 #include linux/slab.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 
 #include media/media-entity.h
 #include media/mt9m032.h
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index d9e9889..f1053f9 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -19,7 +19,7 @@
 #include linux/regulator/consumer.h
 #include linux/slab.h
 #include linux/videodev2.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 
 #include media/mt9t001.h
 #include media/v4l2-ctrls.h
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 93687c1..e0c944a 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -20,7 +20,7 @@
 #include linux/regmap.h
 #include linux/slab.h
 #include linux/videodev2.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/module.h
 
 #include media/mt9v032.h
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 82d2e0a..8ccb7fa 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -34,7 +34,7 @@
 #include linux/regulator/consumer.h
 #include linux/slab.h
 #include linux/smiapp.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include media/v4l2-device.h
 
 #include smiapp.h
diff --git a/drivers/media/i2c/soc_camera/imx074.c 
b/drivers/media/i2c/soc_camera/imx074.c
index f9c0474..48892a1 100644
--- a/drivers/media/i2c/soc_camera/imx074.c
+++ b/drivers/media/i2c/soc_camera/imx074.c
@@ -12,7 +12,7 @@
 
 #include linux/delay.h
 #include linux/i2c.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/slab.h
 #include linux/videodev2.h
 #include linux/module.h
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index d140c7a..2b1179f 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -13,7 +13,7 @@
 #include linux/log2.h
 #include linux/gpio.h
 #include linux/delay.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/module.h
 
 #include media/soc_camera.h
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c 
b/drivers/media/i2c/soc_camera/mt9t031.c
index 13177ca..d6b1503 100644
--- a/drivers/media/i2c/soc_camera/mt9t031.c
+++ b/drivers/media/i2c/soc_camera/mt9t031.c
@@ -13,7 +13,7 @@
 #include linux/log2.h
 #include linux/pm.h
 #include linux/slab.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/videodev2.h
 #include linux/module.h
 
diff --git a/drivers/media/i2c/soc_camera/mt9t112.c 
b/drivers/media/i2c/soc_camera/mt9t112.c
index 6ef9665..59396de 100644
--- a/drivers/media/i2c/soc_camera/mt9t112.c
+++ b/drivers/media/i2c/soc_camera/mt9t112.c
@@ -22,7 +22,7 @@
 #include linux/init.h
 #include linux/module.h
 #include linux/slab.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/videodev2.h
 
 #include media/mt9t112.h
diff --git a/drivers/media/i2c/soc_camera/ov2640.c 
b/drivers/media/i2c/soc_camera/ov2640.c
index bc3ca24..dcc6fa8 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -18,7 +18,7 @@
 #include linux/i2c.h
 #include linux/slab.h
 #include linux/delay.h
-#include linux/v4l2-mediabus.h
+#include linux/v4l2-mbus.h
 #include linux/videodev2.h
 
 #include media/soc_camera.h
diff --git a/drivers/media/i2c/soc_camera/ov5642.c 
b/drivers/media/i2c/soc_camera/ov5642.c
index 5f43e03..73111bd 100644
--- a/drivers/media/i2c/soc_camera/ov5642.c
+++ b/drivers/media/i2c/soc_camera/ov5642.c
@@ -21,7 +21,7 @@
 #include linux/slab.h
 #include linux/videodev2.h

[PATCH 02/15] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Update the v4l documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/DocBook/media/Makefile   |   2 +-
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 include/uapi/linux/v4l2-mediabus.h |   2 +
 3 files changed, 157 insertions(+), 155 deletions(-)

diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 8bf7c61..181b7f4 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -86,7 +86,7 @@ ENUMS = \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/dvb/net.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/dvb/video.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media.h) \
-   $(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-mediabus.h) \
+   $(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media-bus-format.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-subdev.h)
 
 STRUCTS = \
diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..18730b9 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -86,7 +86,7 @@
   green and 5-bit blue values padded on the high bit, transferred as 2 
8-bit
   samples per pixel with the most significant bits (padding, red and half 
of
   the green value) transferred first will be named
-  constantV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/constant.
+  constantMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/constant.
   /para
 
   paraThe following tables list existing packed RGB formats./para
@@ -176,8 +176,8 @@
/row
  /thead
  tbody valign=top
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
  dash-ent-24;
@@ -204,8 +204,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
  dash-ent-24;
@@ -232,8 +232,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
  dash-ent-24;
@@ -260,8 +260,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_LE/entry
  entry0x1004/entry
  entry/entry
  dash-ent-24;
@@ -288,8 +288,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-BE
- entryV4L2_MBUS_FMT_BGR565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-BE
+ entryMEDIA_BUS_FMT_BGR565_2X8_BE/entry
  entry0x1005/entry
  entry/entry
  dash-ent-24;
@@ -316,8 +316,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-LE
- entryV4L2_MBUS_FMT_BGR565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-LE
+ entryMEDIA_BUS_FMT_BGR565_2X8_LE/entry
  entry0x1006/entry
  entry/entry
  dash-ent-24;
@@ -344,8 +344,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-BE
- entryV4L2_MBUS_FMT_RGB565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT

[PATCH 08/15] staging: media: Make use of media_bus_format enum

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all media drivers residing in staging.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  18 ++--
 .../staging/media/davinci_vpfe/dm365_ipipe_hw.c|  26 +++---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 100 ++---
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  90 +--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  96 ++--
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  18 ++--
 drivers/staging/media/omap4iss/iss_csi2.c  |  62 ++---
 drivers/staging/media/omap4iss/iss_ipipe.c |  16 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  28 +++---
 drivers/staging/media/omap4iss/iss_resizer.c   |  26 +++---
 drivers/staging/media/omap4iss/iss_video.c |  78 
 drivers/staging/media/omap4iss/iss_video.h |  10 +--
 12 files changed, 284 insertions(+), 284 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index bdc7f00..704fa20 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -37,15 +37,15 @@
 
 /* ipipe input format's */
 static const unsigned int ipipe_input_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_SGRBG12_1X12,
-   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
-   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
+   MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
 };
 
 /* ipipe output format's */
 static const unsigned int ipipe_output_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
 };
 
 static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
@@ -1457,7 +1457,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use SBGGR10 as default */
if (i = ARRAY_SIZE(ipipe_input_fmts))
-   fmt-code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   fmt-code = MEDIA_BUS_FMT_SGRBG12_1X12;
} else if (pad == IPIPE_PAD_SOURCE) {
for (i = 0; i  ARRAY_SIZE(ipipe_output_fmts); i++)
if (fmt-code == ipipe_output_fmts[i])
@@ -1465,7 +1465,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use UYVY as default */
if (i = ARRAY_SIZE(ipipe_output_fmts))
-   fmt-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   fmt-code = MEDIA_BUS_FMT_UYVY8_2X8;
}
 
fmt-width = clamp_t(u32, fmt-width, MIN_OUT_HEIGHT, max_out_width);
@@ -1642,7 +1642,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SINK;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
@@ -1650,7 +1650,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SOURCE;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
+   format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index b2daf5e..4a0895b2 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -196,12 +196,12 @@ ipipe_setup_resizer(void *__iomem rsz_base, struct 
resizer_params *params)
rsz_set_rsz_regs(rsz_base, RSZ_B, params);
 }
 
-static u32 ipipe_get_color_pat(enum v4l2_mbus_pixelcode pix)
+static u32 ipipe_get_color_pat(enum media_bus_format pix)
 {
switch (pix) {
-   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
return ipipe_sgrbg_pattern;
 
default:
@@ -211,23 +211,23 @@ static u32

[PATCH 04/15] [media] i2c: Make use of media_bus_format enum

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definitions to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in i2c drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/i2c/adv7170.c   | 16 +++
 drivers/media/i2c/adv7175.c   | 16 +++
 drivers/media/i2c/adv7180.c   |  6 +--
 drivers/media/i2c/adv7183.c   |  6 +--
 drivers/media/i2c/adv7604.c   | 72 +++
 drivers/media/i2c/adv7842.c   |  6 +--
 drivers/media/i2c/ak881x.c|  8 ++--
 drivers/media/i2c/cx25840/cx25840-core.c  |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c|  6 +--
 drivers/media/i2c/ml86v7667.c |  6 +--
 drivers/media/i2c/mt9m032.c   |  6 +--
 drivers/media/i2c/mt9p031.c   |  8 ++--
 drivers/media/i2c/mt9t001.c   |  8 ++--
 drivers/media/i2c/mt9v011.c   |  6 +--
 drivers/media/i2c/mt9v032.c   | 12 +++---
 drivers/media/i2c/noon010pc30.c   | 12 +++---
 drivers/media/i2c/ov7670.c| 16 +++
 drivers/media/i2c/ov9650.c| 10 ++---
 drivers/media/i2c/s5c73m3/s5c73m3.h   |  6 +--
 drivers/media/i2c/s5k4ecgx.c  |  4 +-
 drivers/media/i2c/s5k5baf.c   | 14 +++---
 drivers/media/i2c/s5k6a3.c|  2 +-
 drivers/media/i2c/s5k6aa.c|  8 ++--
 drivers/media/i2c/saa6752hs.c |  6 +--
 drivers/media/i2c/saa7115.c   |  2 +-
 drivers/media/i2c/saa717x.c   |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 32 +++---
 drivers/media/i2c/soc_camera/imx074.c |  8 ++--
 drivers/media/i2c/soc_camera/mt9m001.c| 14 +++---
 drivers/media/i2c/soc_camera/mt9m111.c| 70 +++---
 drivers/media/i2c/soc_camera/mt9t031.c| 10 ++---
 drivers/media/i2c/soc_camera/mt9t112.c| 22 +-
 drivers/media/i2c/soc_camera/mt9v022.c| 26 +--
 drivers/media/i2c/soc_camera/ov2640.c | 54 +++
 drivers/media/i2c/soc_camera/ov5642.c |  8 ++--
 drivers/media/i2c/soc_camera/ov6650.c | 58 -
 drivers/media/i2c/soc_camera/ov772x.c | 20 -
 drivers/media/i2c/soc_camera/ov9640.c | 40 -
 drivers/media/i2c/soc_camera/ov9740.c | 12 +++---
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 54 +++
 drivers/media/i2c/soc_camera/tw9910.c | 10 ++---
 drivers/media/i2c/sr030pc30.c | 14 +++---
 drivers/media/i2c/tvp514x.c   | 12 +++---
 drivers/media/i2c/tvp5150.c   |  6 +--
 drivers/media/i2c/tvp7002.c   | 10 ++---
 drivers/media/i2c/vs6624.c| 18 
 46 files changed, 382 insertions(+), 382 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index 04bb297..0f6c852 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { pass_through, play_back };
 
-static enum v4l2_mbus_pixelcode adv7170_codes[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_UYVY8_1X16,
+static enum media_bus_format adv7170_codes[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_1X16,
 };
 
 /* --- */
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
 }
 
 static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-   enum v4l2_mbus_pixelcode *code)
+   enum media_bus_format *code)
 {
if (index = ARRAY_SIZE(adv7170_codes))
return -EINVAL;
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd,
u8 val = adv7170_read(sd, 0x7);
 
if ((val  0x40) == (1  6))
-   mf-code = V4L2_MBUS_FMT_UYVY8_1X16;
+   mf-code = MEDIA_BUS_FMT_UYVY8_1X16;
else
-   mf-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   mf-code = MEDIA_BUS_FMT_UYVY8_2X8;
 
mf-colorspace  = V4L2_COLORSPACE_SMPTE170M;
mf-width   = 0;
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
int ret;
 
switch (mf-code) {
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
val = ~0x40;
break;
 
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
val |= 0x40;
break;
 
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index b88f3b3..3a7c461 100644
--- a/drivers/media/i2c/adv7175.c
+++ b/drivers/media/i2c/adv7175.c
@@ -60,9

[PATCH 06/15] [media] platform: Make use of media_bus_format enum

2014-11-04 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all platform drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   6 +-
 arch/arm/mach-davinci/dm365.c  |   6 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/media/platform/blackfin/bfin_capture.c |  14 +--
 drivers/media/platform/davinci/vpbe.c  |   2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |   4 +-
 drivers/media/platform/exynos-gsc/gsc-core.c   |   8 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |   2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-core.h  |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  16 +--
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |  26 ++---
 drivers/media/platform/exynos4-is/fimc-lite.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-reg.c   |  14 +--
 drivers/media/platform/exynos4-is/mipi-csis.c  |  14 +--
 drivers/media/platform/marvell-ccic/mcam-core.c|  22 ++--
 drivers/media/platform/marvell-ccic/mcam-core.h|   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  | 112 ++---
 drivers/media/platform/omap3isp/ispccp2.c  |  18 ++--
 drivers/media/platform/omap3isp/ispcsi2.c  |  42 
 drivers/media/platform/omap3isp/isppreview.c   |  58 +--
 drivers/media/platform/omap3isp/ispresizer.c   |  18 ++--
 drivers/media/platform/omap3isp/ispvideo.c |  94 -
 drivers/media/platform/omap3isp/ispvideo.h |  10 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  10 +-
 drivers/media/platform/s3c-camif/camif-regs.c  |   8 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c   |   2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c|   2 +-
 drivers/media/platform/sh_vou.c|   8 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |  22 ++--
 drivers/media/platform/soc_camera/mx2_camera.c |  24 ++---
 drivers/media/platform/soc_camera/mx3_camera.c |   6 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |  36 +++
 drivers/media/platform/soc_camera/pxa_camera.c |  16 +--
 drivers/media/platform/soc_camera/rcar_vin.c   |  14 +--
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  20 ++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  38 +++
 drivers/media/platform/soc_camera/soc_camera.c |   2 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |  78 +++---
 drivers/media/platform/via-camera.c|   8 +-
 drivers/media/platform/vsp1/vsp1_bru.c |  14 +--
 drivers/media/platform/vsp1/vsp1_hsit.c|  12 +--
 drivers/media/platform/vsp1/vsp1_lif.c |  10 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  14 +--
 drivers/media/platform/vsp1/vsp1_rwpf.c|  10 +-
 drivers/media/platform/vsp1/vsp1_sru.c |  12 +--
 drivers/media/platform/vsp1/vsp1_uds.c |  10 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  42 
 include/media/davinci/vpbe.h   |   2 +-
 include/media/davinci/vpbe_venc.h  |   4 +-
 include/media/exynos-fimc.h|   2 +-
 include/media/soc_camera.h |   2 +-
 include/media/soc_mediabus.h   |   6 +-
 59 files changed, 485 insertions(+), 485 deletions(-)

diff --git a/Documentation/video4linux/soc-camera.txt 
b/Documentation/video4linux/soc-camera.txt
index daa9e2a..84f41cf 100644
--- a/Documentation/video4linux/soc-camera.txt
+++ b/Documentation/video4linux/soc-camera.txt
@@ -151,7 +151,7 @@ they are transferred over a media bus. Soc-camera provides 
support to
 conveniently manage these formats. A table of standard transformations is
 maintained by soc-camera core, which describes, what FOURCC pixel format will
 be obtained, if a media-bus pixel format is stored in memory according to
-certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
+certain rules. E.g. if MEDIA_BUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
 sample and stored in memory in the little-endian order with no gaps between
 bytes, data in memory will represent the V4L2_PIX_FMT_YUYV FOURCC format. These
 standard transformations will be used by soc

Re: [PATCH 01/15] [media] Move mediabus format definition to a more standard place

2014-11-04 Thread Boris Brezillon
Hi Hans,

On Tue, 04 Nov 2014 11:20:40 +0100
Hans Verkuil hansv...@cisco.com wrote:

 Hi Boris,
 
 On 11/04/14 10:54, Boris Brezillon wrote:
  Rename mediabus formats and move the enum into a separate header file so
  that it can be used by DRM/KMS subsystem without any reference to the V4L2
  subsystem.
  
  Old V4L2_MBUS_FMT_ definitions are now referencing MEDIA_BUS_FMT_ value.
 
 I missed earlier that v4l2-mediabus.h contained a struct as well, so it can't 
 be
 deprecated and neither can a #warning be added.
 
 The best approach, I think, is to use a macro in media-bus-format.h
 that will either define just the MEDIA_BUS value when compiled in the kernel, 
 or
 define both MEDIA_BUS and V4L2_MBUS values when compiled for userspace.
 
 E.g. something like this:
 
 #ifdef __KERNEL__
 #define MEDIA_BUS_FMT_ENTRY(name, val) MEDIA_BUS_FMT_ # name = val
 #else
 /* Keep V4L2_MBUS_FMT for backwards compatibility */
 #define MEDIA_BUS_FMT_ENTRY(name, val) \
   MEDIA_BUS_FMT_ # name = val, \
   V4L2_MBUS_FMT_ # name = val
 #endif

Okay, but this means we keep adding V4L2_MBUS_FMT_ definitions even for
new formats (which definitely doesn't encourage people to move on).
Moreover, we add a V4L2 prefix in what was supposed to be a subsystem
neutral header.

Anyway, these are just nitpicks, and if you prefer this approach
I'll rework my series :-).

 
 An alternative approach is to have v4l2-mediabus.h include media-bus-format.h,
 put #ifndef __KERNEL__ around the enum v4l2_mbus_pixelcode and add a big 
 comment
 there that applications should use the defines from media-bus-format.h and 
 that
 this enum is frozen (i.e. new values are only added to media-bus-format.h).
 
 But I think I like the macro idea best.

As you wish, my only intent is to use those bus format definitions in a
DRM driver :-).

Thanks,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/15] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-05 Thread Boris Brezillon
Hi Sakari,

On Wed, 5 Nov 2014 16:57:27 +0200
Sakari Ailus sakari.ai...@iki.fi wrote:

 Hi Boris,
 
 On Tue, Nov 04, 2014 at 10:54:57AM +0100, Boris Brezillon wrote:
  In order to have subsytem agnostic media bus format definitions we've
  moved media bus definition to include/uapi/linux/media-bus-format.h and
  prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.
  
  Update the v4l documentation accordingly.
  
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  ---
   Documentation/DocBook/media/Makefile   |   2 +-
   Documentation/DocBook/media/v4l/subdev-formats.xml | 308 
  ++---
   include/uapi/linux/v4l2-mediabus.h |   2 +
   3 files changed, 157 insertions(+), 155 deletions(-)
  
 
 ...
 
  diff --git a/include/uapi/linux/v4l2-mediabus.h 
  b/include/uapi/linux/v4l2-mediabus.h
  index f471064..9fbe891 100644
  --- a/include/uapi/linux/v4l2-mediabus.h
  +++ b/include/uapi/linux/v4l2-mediabus.h
  @@ -32,6 +32,8 @@ enum v4l2_mbus_pixelcode {
  MEDIA_BUS_TO_V4L2_MBUS(RGB888_2X12_BE),
  MEDIA_BUS_TO_V4L2_MBUS(RGB888_2X12_LE),
  MEDIA_BUS_TO_V4L2_MBUS(ARGB_1X32),
  +   MEDIA_BUS_TO_V4L2_MBUS(RGB444_1X12),
  +   MEDIA_BUS_TO_V4L2_MBUS(RGB565_1X16),
 
 Shouldn't this to go to a separate patch?

Absolutely, some changes from a different patch have slipped into this
one.

I'll fix that.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 11/15] [media] Deprecate v4l2_mbus_pixelcode

2014-11-05 Thread Boris Brezillon
On Wed, 5 Nov 2014 17:08:15 +0200
Sakari Ailus sakari.ai...@iki.fi wrote:

 Hi Boris,
 
 On Tue, Nov 04, 2014 at 10:55:06AM +0100, Boris Brezillon wrote:
  The v4l2_mbus_pixelcode enum (or its values) should be replaced by the
  media_bus_format enum.
  Keep this enum in v4l2-mediabus.h and create a new header containing
  the v4l2_mbus_framefmt struct definition (which is not deprecated) so
  that we can add a #warning statement in v4l2-mediabus.h and hopefully
  encourage users to move to the new definitions.
  
  Replace inclusion of v4l2-mediabus.h with v4l2-mbus.h in all common headers
  and update the documentation Makefile to parse v4l2-mbus.h instead of
  v4l2-mediabus.h.
  
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  ---
   Documentation/DocBook/media/Makefile |  2 +-
   include/media/v4l2-mediabus.h|  2 +-
   include/uapi/linux/Kbuild|  1 +
   include/uapi/linux/v4l2-mbus.h   | 35 
  +++
   include/uapi/linux/v4l2-mediabus.h   | 26 --
 
 I would keep the original file name, even if the compatibility definitions
 are there. I don't see any harm in having them around as well.
 

That's the part I was not sure about.
The goal of this patch (and the following ones) is to deprecate
v4l2_mbus_pixelcode enum and its values by adding a #warning when
v4l2-mediabus.h file is included, thus encouraging people to use new
definitions.

Do you see another solution to generate such warnings at compilation
time ?

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 11/15] [media] Deprecate v4l2_mbus_pixelcode

2014-11-05 Thread Boris Brezillon
On Wed, 05 Nov 2014 16:19:56 +0100
Hans Verkuil hansv...@cisco.com wrote:

 
 
 On 11/05/14 16:15, Boris Brezillon wrote:
  On Wed, 5 Nov 2014 17:08:15 +0200
  Sakari Ailus sakari.ai...@iki.fi wrote:
  
  Hi Boris,
 
  On Tue, Nov 04, 2014 at 10:55:06AM +0100, Boris Brezillon wrote:
  The v4l2_mbus_pixelcode enum (or its values) should be replaced by the
  media_bus_format enum.
  Keep this enum in v4l2-mediabus.h and create a new header containing
  the v4l2_mbus_framefmt struct definition (which is not deprecated) so
  that we can add a #warning statement in v4l2-mediabus.h and hopefully
  encourage users to move to the new definitions.
 
  Replace inclusion of v4l2-mediabus.h with v4l2-mbus.h in all common 
  headers
  and update the documentation Makefile to parse v4l2-mbus.h instead of
  v4l2-mediabus.h.
 
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  ---
   Documentation/DocBook/media/Makefile |  2 +-
   include/media/v4l2-mediabus.h|  2 +-
   include/uapi/linux/Kbuild|  1 +
   include/uapi/linux/v4l2-mbus.h   | 35 
  +++
   include/uapi/linux/v4l2-mediabus.h   | 26 --
 
  I would keep the original file name, even if the compatibility definitions
  are there. I don't see any harm in having them around as well.
 
  
  That's the part I was not sure about.
  The goal of this patch (and the following ones) is to deprecate
  v4l2_mbus_pixelcode enum and its values by adding a #warning when
  v4l2-mediabus.h file is included, thus encouraging people to use new
  definitions.
 
 Since v4l2-mediabus.h contains struct v4l2_mbus_framefmt this header remains
 a legal header, so you can't use #warning here in any case.
 

Actually this patch moves the struct v4l2_mbus_framefmt definition into
another header before adding the warning statement.

Anyway, this is really a detail, and if everybody agrees that we should
just leave the old definition in place, I'm fine with that.


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] [media] Move mediabus format definition to a more standard place

2014-11-05 Thread Boris Brezillon
On Wed, 5 Nov 2014 17:00:25 +0200
Sakari Ailus sakari.ai...@iki.fi wrote:

 Hi,
 
 On Tue, Nov 04, 2014 at 12:09:59PM +0100, Hans Verkuil wrote:
  Well, I gave two alternatives :-)
  
  Both are fine as far as I am concerned, but it would be nice to hear
  what others think.
 
 In fact I think both are good options. :-)
 
 I'd perhaps lean towards the latter, for it has the benefit of pushing to
 use the new definitions and the old ones can be deprecated (and eventually
 removed in year 2030 or so ;)).
 
 Either way, preprocessor macros should be used instead of an enum since that
 way it's possible to figure out at that phase whether something is defined
 or not. There is for enums, too, but it results in a compilation error...
 

I don't get that last part :-).

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/10] [media] Make use of the new media_bus_format definitions

2014-11-06 Thread Boris Brezillon
Replace references to the v4l2_mbus_pixelcode enum with the new
media_bus_format enum in all common headers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/media/v4l2-mediabus.h| 2 +-
 include/media/v4l2-subdev.h  | 2 +-
 include/uapi/linux/v4l2-subdev.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 395c4a9..4915621 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -98,7 +98,7 @@ static inline void v4l2_fill_pix_format(struct 
v4l2_pix_format *pix_fmt,
 
 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
   const struct v4l2_pix_format *pix_fmt,
-  enum v4l2_mbus_pixelcode code)
+  enum media_bus_format code)
 {
mbus_fmt-width = pix_fmt-width;
mbus_fmt-height = pix_fmt-height;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d746572..9af5932 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -341,7 +341,7 @@ struct v4l2_subdev_video_ops {
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
-enum v4l2_mbus_pixelcode *code);
+enum media_bus_format *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a619cdd..7f44f04 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -68,7 +68,7 @@ struct v4l2_subdev_crop {
  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  */
 struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -81,7 +81,7 @@ struct v4l2_subdev_mbus_code_enum {
  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  */
 struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -109,7 +109,7 @@ struct v4l2_subdev_frame_interval {
  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
  * @pad: pad number, as reported by the media API
  * @index: frame interval index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/10] [media] Make mediabus format subsystem neutral

2014-11-06 Thread Boris Brezillon
Hello,

This patch series prepares the use of media bus formats outside of
the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
driver where I have to configure my DPI/RGB bus according to the
connected display).

The series first defines a new enum with a neutral name (media_bus_format),
and then replace all references to the old enum and its values within the
kernel.

Best Regards,

Boris

Changes since v1:
- drop patches deprecating v4l2_mbus_pixelcode for user-space users
- put V4L2 legacy format definitions into media-bus-format.h

Boris Brezillon (10):
  [media] Move mediabus format definition to a more standard place
  [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values
  [media] Make use of the new media_bus_format definitions
  [media] i2c: Make use of media_bus_format enum
  [media] pci: Make use of media_bus_format enum
  [media] platform: Make use of media_bus_format enum
  [media] usb: Make use of media_bus_format enum
  staging: media: Make use of media_bus_format enum
  gpu: ipu-v3: Make use of media_bus_format enum
  [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the
kernel

 Documentation/DocBook/media/Makefile   |   2 +-
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   6 +-
 arch/arm/mach-davinci/dm365.c  |   6 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |  66 ++---
 drivers/media/i2c/adv7170.c|  16 +-
 drivers/media/i2c/adv7175.c|  16 +-
 drivers/media/i2c/adv7180.c|   6 +-
 drivers/media/i2c/adv7183.c|   6 +-
 drivers/media/i2c/adv7604.c|  72 ++---
 drivers/media/i2c/adv7842.c|   6 +-
 drivers/media/i2c/ak881x.c |   8 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   6 +-
 drivers/media/i2c/ml86v7667.c  |   6 +-
 drivers/media/i2c/mt9m032.c|   6 +-
 drivers/media/i2c/mt9p031.c|   8 +-
 drivers/media/i2c/mt9t001.c|   8 +-
 drivers/media/i2c/mt9v011.c|   6 +-
 drivers/media/i2c/mt9v032.c|  12 +-
 drivers/media/i2c/noon010pc30.c|  12 +-
 drivers/media/i2c/ov7670.c |  16 +-
 drivers/media/i2c/ov9650.c |  10 +-
 drivers/media/i2c/s5c73m3/s5c73m3.h|   6 +-
 drivers/media/i2c/s5k4ecgx.c   |   4 +-
 drivers/media/i2c/s5k5baf.c|  14 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   8 +-
 drivers/media/i2c/saa6752hs.c  |   6 +-
 drivers/media/i2c/saa7115.c|   2 +-
 drivers/media/i2c/saa717x.c|   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  32 +--
 drivers/media/i2c/soc_camera/imx074.c  |   8 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  14 +-
 drivers/media/i2c/soc_camera/mt9m111.c |  70 ++---
 drivers/media/i2c/soc_camera/mt9t031.c |  10 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  22 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  26 +-
 drivers/media/i2c/soc_camera/ov2640.c  |  54 ++--
 drivers/media/i2c/soc_camera/ov5642.c  |   8 +-
 drivers/media/i2c/soc_camera/ov6650.c  |  58 ++--
 drivers/media/i2c/soc_camera/ov772x.c  |  20 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  40 +--
 drivers/media/i2c/soc_camera/ov9740.c  |  12 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  54 ++--
 drivers/media/i2c/soc_camera/tw9910.c  |  10 +-
 drivers/media/i2c/sr030pc30.c  |  14 +-
 drivers/media/i2c/tvp514x.c|  12 +-
 drivers/media/i2c/tvp5150.c|   6 +-
 drivers/media/i2c/tvp7002.c|  10 +-
 drivers/media/i2c/vs6624.c |  18 +-
 drivers/media/pci/cx18/cx18-av-core.c  |   2 +-
 drivers/media/pci/cx18/cx18-controls.c |   2 +-
 drivers/media/pci/cx18/cx18-ioctl.c|   2 +-
 drivers/media/pci/cx23885/cx23885-video.c  |   2 +-
 drivers/media/pci/ivtv/ivtv-controls.c |   2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c|   2 +-
 drivers/media/pci

[PATCH v2 01/10] [media] Move mediabus format definition to a more standard place

2014-11-06 Thread Boris Brezillon
Rename mediabus formats and move the enum into a separate header file so
that it can be used by DRM/KMS subsystem without any reference to the V4L2
subsystem.

Old v4l2_mbus_pixelcode now points to media_bus_format.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/media-bus-format.h | 131 ++
 include/uapi/linux/v4l2-mediabus.h| 114 +
 3 files changed, 134 insertions(+), 112 deletions(-)
 create mode 100644 include/uapi/linux/media-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e..b2c23f8 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -414,6 +414,7 @@ header-y += veth.h
 header-y += vfio.h
 header-y += vhost.h
 header-y += videodev2.h
+header-y += media-bus-format.h
 header-y += virtio_9p.h
 header-y += virtio_balloon.h
 header-y += virtio_blk.h
diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
new file mode 100644
index 000..251a902
--- /dev/null
+++ b/include/uapi/linux/media-bus-format.h
@@ -0,0 +1,131 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MEDIA_BUS_FORMAT_H
+#define __LINUX_MEDIA_BUS_FORMAT_H
+
+/*
+ * These bus formats uniquely identify data formats on the data bus. Format 0
+ * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where
+ * the data format is fixed. Additionally, 2X8 means that one pixel is
+ * transferred in two 8-bit samples, BE or LE specify in which order those
+ * samples are transferred over the bus: LE means that the least significant
+ * bits are transferred first, BE means that the most significant bits are
+ * transferred first, and PADHI and PADLO define which bits - low or high,
+ * in the incomplete high byte, are filled with padding bits.
+ *
+ * The bus formats are grouped by type, bus_width, bits per component, samples
+ * per pixel and order of subsamples. Numerical values are sorted using generic
+ * numerical sort order (8 thus comes before 10).
+ *
+ * As their value can't change when a new bus format is inserted in the
+ * enumeration, the bus formats are explicitly given a numerical value. The 
next
+ * free values for each category are listed below, update them when inserting
+ * new pixel codes.
+ */
+
+#define MEDIA_BUS_FMT_ENTRY(name, val) \
+   MEDIA_BUS_FMT_ ## name = val,   \
+   V4L2_MBUS_FMT_ ## name = val
+
+enum media_bus_format {
+   MEDIA_BUS_FMT_ENTRY(FIXED, 0x0001),
+
+   /* RGB - next is 0x100e */
+   MEDIA_BUS_FMT_ENTRY(RGB444_2X8_PADHI_BE, 0x1001),
+   MEDIA_BUS_FMT_ENTRY(RGB444_2X8_PADHI_LE, 0x1002),
+   MEDIA_BUS_FMT_ENTRY(RGB555_2X8_PADHI_BE, 0x1003),
+   MEDIA_BUS_FMT_ENTRY(RGB555_2X8_PADHI_LE, 0x1004),
+   MEDIA_BUS_FMT_ENTRY(BGR565_2X8_BE, 0x1005),
+   MEDIA_BUS_FMT_ENTRY(BGR565_2X8_LE, 0x1006),
+   MEDIA_BUS_FMT_ENTRY(RGB565_2X8_BE, 0x1007),
+   MEDIA_BUS_FMT_ENTRY(RGB565_2X8_LE, 0x1008),
+   MEDIA_BUS_FMT_ENTRY(RGB666_1X18, 0x1009),
+   MEDIA_BUS_FMT_ENTRY(RGB888_1X24, 0x100a),
+   MEDIA_BUS_FMT_ENTRY(RGB888_2X12_BE, 0x100b),
+   MEDIA_BUS_FMT_ENTRY(RGB888_2X12_LE, 0x100c),
+   MEDIA_BUS_FMT_ENTRY(ARGB_1X32, 0x100d),
+
+   /* YUV (including grey) - next is 0x2024 */
+   MEDIA_BUS_FMT_ENTRY(Y8_1X8, 0x2001),
+   MEDIA_BUS_FMT_ENTRY(UV8_1X8, 0x2015),
+   MEDIA_BUS_FMT_ENTRY(UYVY8_1_5X8, 0x2002),
+   MEDIA_BUS_FMT_ENTRY(VYUY8_1_5X8, 0x2003),
+   MEDIA_BUS_FMT_ENTRY(YUYV8_1_5X8, 0x2004),
+   MEDIA_BUS_FMT_ENTRY(YVYU8_1_5X8, 0x2005),
+   MEDIA_BUS_FMT_ENTRY(UYVY8_2X8, 0x2006),
+   MEDIA_BUS_FMT_ENTRY(VYUY8_2X8, 0x2007),
+   MEDIA_BUS_FMT_ENTRY(YUYV8_2X8, 0x2008),
+   MEDIA_BUS_FMT_ENTRY(YVYU8_2X8, 0x2009),
+   MEDIA_BUS_FMT_ENTRY(Y10_1X10, 0x200a),
+   MEDIA_BUS_FMT_ENTRY(UYVY10_2X10, 0x2018),
+   MEDIA_BUS_FMT_ENTRY(VYUY10_2X10, 0x2019),
+   MEDIA_BUS_FMT_ENTRY(YUYV10_2X10, 0x200b),
+   MEDIA_BUS_FMT_ENTRY(YVYU10_2X10, 0x200c),
+   MEDIA_BUS_FMT_ENTRY(Y12_1X12, 0x2013),
+   MEDIA_BUS_FMT_ENTRY(UYVY8_1X16, 0x200f),
+   MEDIA_BUS_FMT_ENTRY(VYUY8_1X16, 0x2010),
+   MEDIA_BUS_FMT_ENTRY(YUYV8_1X16, 0x2011),
+   MEDIA_BUS_FMT_ENTRY(YVYU8_1X16, 0x2012),
+   MEDIA_BUS_FMT_ENTRY(YDYUYDYV8_1X16, 0x2014),
+   MEDIA_BUS_FMT_ENTRY(UYVY10_1X20, 0x201a),
+   MEDIA_BUS_FMT_ENTRY(VYUY10_1X20, 0x201b),
+   MEDIA_BUS_FMT_ENTRY(YUYV10_1X20, 0x200d),
+   MEDIA_BUS_FMT_ENTRY(YVYU10_1X20, 0x200e),
+   MEDIA_BUS_FMT_ENTRY(YUV10_1X30, 0x2016),
+   MEDIA_BUS_FMT_ENTRY

[PATCH v2 02/10] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Update the v4l documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/DocBook/media/Makefile   |   2 +-
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 2 files changed, 155 insertions(+), 155 deletions(-)

diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 8bf7c61..181b7f4 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -86,7 +86,7 @@ ENUMS = \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/dvb/net.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/dvb/video.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media.h) \
-   $(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-mediabus.h) \
+   $(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media-bus-format.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-subdev.h)
 
 STRUCTS = \
diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..18730b9 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -86,7 +86,7 @@
   green and 5-bit blue values padded on the high bit, transferred as 2 
8-bit
   samples per pixel with the most significant bits (padding, red and half 
of
   the green value) transferred first will be named
-  constantV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/constant.
+  constantMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/constant.
   /para
 
   paraThe following tables list existing packed RGB formats./para
@@ -176,8 +176,8 @@
/row
  /thead
  tbody valign=top
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
  dash-ent-24;
@@ -204,8 +204,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
  dash-ent-24;
@@ -232,8 +232,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
  dash-ent-24;
@@ -260,8 +260,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_LE/entry
  entry0x1004/entry
  entry/entry
  dash-ent-24;
@@ -288,8 +288,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-BE
- entryV4L2_MBUS_FMT_BGR565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-BE
+ entryMEDIA_BUS_FMT_BGR565_2X8_BE/entry
  entry0x1005/entry
  entry/entry
  dash-ent-24;
@@ -316,8 +316,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-LE
- entryV4L2_MBUS_FMT_BGR565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-LE
+ entryMEDIA_BUS_FMT_BGR565_2X8_LE/entry
  entry0x1006/entry
  entry/entry
  dash-ent-24;
@@ -344,8 +344,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-BE
- entryV4L2_MBUS_FMT_RGB565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-BE
+ entryMEDIA_BUS_FMT_RGB565_2X8_BE

[PATCH v2 04/10] [media] i2c: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definitions to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in i2c drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/i2c/adv7170.c   | 16 +++
 drivers/media/i2c/adv7175.c   | 16 +++
 drivers/media/i2c/adv7180.c   |  6 +--
 drivers/media/i2c/adv7183.c   |  6 +--
 drivers/media/i2c/adv7604.c   | 72 +++
 drivers/media/i2c/adv7842.c   |  6 +--
 drivers/media/i2c/ak881x.c|  8 ++--
 drivers/media/i2c/cx25840/cx25840-core.c  |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c|  6 +--
 drivers/media/i2c/ml86v7667.c |  6 +--
 drivers/media/i2c/mt9m032.c   |  6 +--
 drivers/media/i2c/mt9p031.c   |  8 ++--
 drivers/media/i2c/mt9t001.c   |  8 ++--
 drivers/media/i2c/mt9v011.c   |  6 +--
 drivers/media/i2c/mt9v032.c   | 12 +++---
 drivers/media/i2c/noon010pc30.c   | 12 +++---
 drivers/media/i2c/ov7670.c| 16 +++
 drivers/media/i2c/ov9650.c| 10 ++---
 drivers/media/i2c/s5c73m3/s5c73m3.h   |  6 +--
 drivers/media/i2c/s5k4ecgx.c  |  4 +-
 drivers/media/i2c/s5k5baf.c   | 14 +++---
 drivers/media/i2c/s5k6a3.c|  2 +-
 drivers/media/i2c/s5k6aa.c|  8 ++--
 drivers/media/i2c/saa6752hs.c |  6 +--
 drivers/media/i2c/saa7115.c   |  2 +-
 drivers/media/i2c/saa717x.c   |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 32 +++---
 drivers/media/i2c/soc_camera/imx074.c |  8 ++--
 drivers/media/i2c/soc_camera/mt9m001.c| 14 +++---
 drivers/media/i2c/soc_camera/mt9m111.c| 70 +++---
 drivers/media/i2c/soc_camera/mt9t031.c| 10 ++---
 drivers/media/i2c/soc_camera/mt9t112.c| 22 +-
 drivers/media/i2c/soc_camera/mt9v022.c| 26 +--
 drivers/media/i2c/soc_camera/ov2640.c | 54 +++
 drivers/media/i2c/soc_camera/ov5642.c |  8 ++--
 drivers/media/i2c/soc_camera/ov6650.c | 58 -
 drivers/media/i2c/soc_camera/ov772x.c | 20 -
 drivers/media/i2c/soc_camera/ov9640.c | 40 -
 drivers/media/i2c/soc_camera/ov9740.c | 12 +++---
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 54 +++
 drivers/media/i2c/soc_camera/tw9910.c | 10 ++---
 drivers/media/i2c/sr030pc30.c | 14 +++---
 drivers/media/i2c/tvp514x.c   | 12 +++---
 drivers/media/i2c/tvp5150.c   |  6 +--
 drivers/media/i2c/tvp7002.c   | 10 ++---
 drivers/media/i2c/vs6624.c| 18 
 46 files changed, 382 insertions(+), 382 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index 04bb297..0f6c852 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { pass_through, play_back };
 
-static enum v4l2_mbus_pixelcode adv7170_codes[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_UYVY8_1X16,
+static enum media_bus_format adv7170_codes[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_1X16,
 };
 
 /* --- */
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
 }
 
 static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-   enum v4l2_mbus_pixelcode *code)
+   enum media_bus_format *code)
 {
if (index = ARRAY_SIZE(adv7170_codes))
return -EINVAL;
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd,
u8 val = adv7170_read(sd, 0x7);
 
if ((val  0x40) == (1  6))
-   mf-code = V4L2_MBUS_FMT_UYVY8_1X16;
+   mf-code = MEDIA_BUS_FMT_UYVY8_1X16;
else
-   mf-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   mf-code = MEDIA_BUS_FMT_UYVY8_2X8;
 
mf-colorspace  = V4L2_COLORSPACE_SMPTE170M;
mf-width   = 0;
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
int ret;
 
switch (mf-code) {
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
val = ~0x40;
break;
 
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
val |= 0x40;
break;
 
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index b88f3b3..3a7c461 100644
--- a/drivers/media/i2c/adv7175.c
+++ b/drivers/media/i2c/adv7175.c
@@ -60,9

[PATCH v2 07/10] [media] usb: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all usb drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++--
 drivers/media/usb/em28xx/em28xx-camera.c  | 2 +-
 drivers/media/usb/go7007/go7007-v4l2.c| 2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 459bb0e..95653ba 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1878,7 +1878,7 @@ static int cx231xx_s_video_encoding(struct 
cx2341x_handler *cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev-sd_cx25840, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 3b3ada6..989d527 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -967,7 +967,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-height = f-fmt.pix.height;
dev-format = fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
 
@@ -1012,7 +1012,7 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id norm)
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
memset(mbus_fmt, 0, sizeof(mbus_fmt));
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = dev-width;
mbus_fmt.height = dev-height;
call_all(dev, video, s_mbus_fmt, mbus_fmt);
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index 6d2ea9a..38cf6c8 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -430,7 +430,7 @@ int em28xx_init_camera(struct em28xx *dev)
break;
}
 
-   fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
+   fmt.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640;
fmt.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, fmt);
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c 
b/drivers/media/usb/go7007/go7007-v4l2.c
index ec799b4..d6bf982 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct 
v4l2_format *fmt, int try)
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt;
 
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt-fmt.pix.width : width;
mbus_fmt.height = height;
go-encoder_h_halve = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 9623b62..2fd9b5e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
memset(fmt, 0, sizeof(fmt));
fmt.width = hdw-res_hor_val;
fmt.height = hdw-res_ver_val;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, subdev v4l2 set_size(%dx%d),
   fmt.width, fmt.height);
v4l2_device_call_all(hdw-v4l2_dev, 0, video, s_mbus_fmt, 
fmt);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 09/10] gpu: ipu-v3: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in the ipu-v3 driver.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 66 ++--
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index d6f56471..752cdd2 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -227,83 +227,83 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, 
u32 pixel_clk,
 static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 {
switch (mbus_code) {
-   case V4L2_MBUS_FMT_BGR565_2X8_BE:
-   case V4L2_MBUS_FMT_BGR565_2X8_LE:
-   case V4L2_MBUS_FMT_RGB565_2X8_BE:
-   case V4L2_MBUS_FMT_RGB565_2X8_LE:
+   case MEDIA_BUS_FMT_BGR565_2X8_BE:
+   case MEDIA_BUS_FMT_BGR565_2X8_LE:
+   case MEDIA_BUS_FMT_RGB565_2X8_BE:
+   case MEDIA_BUS_FMT_RGB565_2X8_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
cfg-mipi_dt = MIPI_DT_RGB565;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB444;
cfg-mipi_dt = MIPI_DT_RGB444;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB555;
cfg-mipi_dt = MIPI_DT_RGB555;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_YUYV8_2X8:
+   case MEDIA_BUS_FMT_YUYV8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_YUYV8_1X16:
+   case MEDIA_BUS_FMT_YUYV8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_SBGGR8_1X8:
-   case V4L2_MBUS_FMT_SGBRG8_1X8:
-   case V4L2_MBUS_FMT_SGRBG8_1X8:
-   case V4L2_MBUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW8;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+   case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW10;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_1X10:
-   case V4L2_MBUS_FMT_SGBRG10_1X10:
-   case V4L2_MBUS_FMT_SGRBG10_1X10:
-   case V4L2_MBUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
cfg-data_fmt

[PATCH v2 05/10] [media] pci: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definition in pci drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/pci/cx18/cx18-av-core.c   | 2 +-
 drivers/media/pci/cx18/cx18-controls.c  | 2 +-
 drivers/media/pci/cx18/cx18-ioctl.c | 2 +-
 drivers/media/pci/cx23885/cx23885-video.c   | 2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c | 2 +-
 drivers/media/pci/saa7134/saa7134-empress.c | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-av-core.c 
b/drivers/media/pci/cx18/cx18-av-core.c
index 2d3afe0..4c6ce21 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, 
struct v4l2_mbus_framefmt
int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
int is_50Hz = !(state-std  V4L2_STD_525_60);
 
-   if (fmt-code != V4L2_MBUS_FMT_FIXED)
+   if (fmt-code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
 
fmt-field = V4L2_FIELD_INTERLACED;
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 282a3d2..4aeb7c6 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 6f2b590..71963db 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
 
mbus_fmt.width = cx-cxhdl.width = w;
mbus_fmt.height = cx-cxhdl.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, mbus_fmt);
return cx18_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f9..091f5db 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -608,7 +608,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-field  = f-fmt.pix.field;
dprintk(2, %s() width=%d height=%d field=%d\n, __func__,
dev-width, dev-height, dev-field);
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
/* s_mbus_fmt overwrites f-fmt.pix.field, restore it */
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 2b0ab26..ccf548c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3e0cb77..4d8ee18 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, 
struct v4l2_format *f
fmt-fmt.pix.width /= 2;
mbus_fmt.width = fmt-fmt.pix.width;
mbus_fmt.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, mbus_fmt);
return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c 
b/drivers/media/pci/saa7134/saa7134-empress.c
index e4ea85f..8b3bb78 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -140,7 +140,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void 
*priv,
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f

[PATCH v2 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-06 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/uapi/linux/media-bus-format.h | 5 +
 include/uapi/linux/v4l2-mediabus.h| 2 ++
 2 files changed, 7 insertions(+)

diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
index 251a902..d7f9ea2 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -31,9 +31,14 @@
  * new pixel codes.
  */
 
+#ifdef __KERNEL__
+#define MEDIA_BUS_FMT_ENTRY(name, val) MEDIA_BUS_FMT_ ## name = val
+#else
+/* Keep V4L2_MBUS_FMT for backwards compatibility */
 #define MEDIA_BUS_FMT_ENTRY(name, val) \
MEDIA_BUS_FMT_ ## name = val,   \
V4L2_MBUS_FMT_ ## name = val
+#endif
 
 enum media_bus_format {
MEDIA_BUS_FMT_ENTRY(FIXED, 0x0001),
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index d30526c..8759002 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,7 +15,9 @@
 #include linux/videodev2.h
 #include linux/media-bus-format.h
 
+#ifndef __KERNEL__
 #define v4l2_mbus_pixelcode media_bus_format
+#endif
 
 /**
  * struct v4l2_mbus_framefmt - frame format on the media bus
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/10] staging: media: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all media drivers residing in staging.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  18 ++--
 .../staging/media/davinci_vpfe/dm365_ipipe_hw.c|  26 +++---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 100 ++---
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  90 +--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  96 ++--
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  18 ++--
 drivers/staging/media/omap4iss/iss_csi2.c  |  62 ++---
 drivers/staging/media/omap4iss/iss_ipipe.c |  16 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  28 +++---
 drivers/staging/media/omap4iss/iss_resizer.c   |  26 +++---
 drivers/staging/media/omap4iss/iss_video.c |  78 
 drivers/staging/media/omap4iss/iss_video.h |  10 +--
 12 files changed, 284 insertions(+), 284 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index bdc7f00..704fa20 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -37,15 +37,15 @@
 
 /* ipipe input format's */
 static const unsigned int ipipe_input_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_SGRBG12_1X12,
-   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
-   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
+   MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
 };
 
 /* ipipe output format's */
 static const unsigned int ipipe_output_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
 };
 
 static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
@@ -1457,7 +1457,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use SBGGR10 as default */
if (i = ARRAY_SIZE(ipipe_input_fmts))
-   fmt-code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   fmt-code = MEDIA_BUS_FMT_SGRBG12_1X12;
} else if (pad == IPIPE_PAD_SOURCE) {
for (i = 0; i  ARRAY_SIZE(ipipe_output_fmts); i++)
if (fmt-code == ipipe_output_fmts[i])
@@ -1465,7 +1465,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use UYVY as default */
if (i = ARRAY_SIZE(ipipe_output_fmts))
-   fmt-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   fmt-code = MEDIA_BUS_FMT_UYVY8_2X8;
}
 
fmt-width = clamp_t(u32, fmt-width, MIN_OUT_HEIGHT, max_out_width);
@@ -1642,7 +1642,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SINK;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
@@ -1650,7 +1650,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SOURCE;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
+   format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index b2daf5e..4a0895b2 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -196,12 +196,12 @@ ipipe_setup_resizer(void *__iomem rsz_base, struct 
resizer_params *params)
rsz_set_rsz_regs(rsz_base, RSZ_B, params);
 }
 
-static u32 ipipe_get_color_pat(enum v4l2_mbus_pixelcode pix)
+static u32 ipipe_get_color_pat(enum media_bus_format pix)
 {
switch (pix) {
-   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
return ipipe_sgrbg_pattern;
 
default:
@@ -211,23 +211,23 @@ static u32

[PATCH v2 06/10] [media] platform: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all platform drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   6 +-
 arch/arm/mach-davinci/dm365.c  |   6 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/media/platform/blackfin/bfin_capture.c |  14 +--
 drivers/media/platform/davinci/vpbe.c  |   2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |   4 +-
 drivers/media/platform/exynos-gsc/gsc-core.c   |   8 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |   2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-core.h  |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  16 +--
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |  26 ++---
 drivers/media/platform/exynos4-is/fimc-lite.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-reg.c   |  14 +--
 drivers/media/platform/exynos4-is/mipi-csis.c  |  14 +--
 drivers/media/platform/marvell-ccic/mcam-core.c|  22 ++--
 drivers/media/platform/marvell-ccic/mcam-core.h|   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  | 112 ++---
 drivers/media/platform/omap3isp/ispccp2.c  |  18 ++--
 drivers/media/platform/omap3isp/ispcsi2.c  |  42 
 drivers/media/platform/omap3isp/isppreview.c   |  58 +--
 drivers/media/platform/omap3isp/ispresizer.c   |  18 ++--
 drivers/media/platform/omap3isp/ispvideo.c |  94 -
 drivers/media/platform/omap3isp/ispvideo.h |  10 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  10 +-
 drivers/media/platform/s3c-camif/camif-regs.c  |   8 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c   |   2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c|   2 +-
 drivers/media/platform/sh_vou.c|   8 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |  22 ++--
 drivers/media/platform/soc_camera/mx2_camera.c |  24 ++---
 drivers/media/platform/soc_camera/mx3_camera.c |   6 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |  36 +++
 drivers/media/platform/soc_camera/pxa_camera.c |  16 +--
 drivers/media/platform/soc_camera/rcar_vin.c   |  14 +--
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  20 ++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  38 +++
 drivers/media/platform/soc_camera/soc_camera.c |   2 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |  78 +++---
 drivers/media/platform/via-camera.c|   8 +-
 drivers/media/platform/vsp1/vsp1_bru.c |  14 +--
 drivers/media/platform/vsp1/vsp1_hsit.c|  12 +--
 drivers/media/platform/vsp1/vsp1_lif.c |  10 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  14 +--
 drivers/media/platform/vsp1/vsp1_rwpf.c|  10 +-
 drivers/media/platform/vsp1/vsp1_sru.c |  12 +--
 drivers/media/platform/vsp1/vsp1_uds.c |  10 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  42 
 include/media/davinci/vpbe.h   |   2 +-
 include/media/davinci/vpbe_venc.h  |   4 +-
 include/media/exynos-fimc.h|   2 +-
 include/media/soc_camera.h |   2 +-
 include/media/soc_mediabus.h   |   6 +-
 59 files changed, 485 insertions(+), 485 deletions(-)

diff --git a/Documentation/video4linux/soc-camera.txt 
b/Documentation/video4linux/soc-camera.txt
index daa9e2a..84f41cf 100644
--- a/Documentation/video4linux/soc-camera.txt
+++ b/Documentation/video4linux/soc-camera.txt
@@ -151,7 +151,7 @@ they are transferred over a media bus. Soc-camera provides 
support to
 conveniently manage these formats. A table of standard transformations is
 maintained by soc-camera core, which describes, what FOURCC pixel format will
 be obtained, if a media-bus pixel format is stored in memory according to
-certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
+certain rules. E.g. if MEDIA_BUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
 sample and stored in memory in the little-endian order with no gaps between
 bytes, data in memory will represent the V4L2_PIX_FMT_YUYV FOURCC format. These
 standard transformations will be used by soc

Re: [PATCH v2 01/10] [media] Move mediabus format definition to a more standard place

2014-11-07 Thread Boris Brezillon
On Fri, 7 Nov 2014 13:43:59 +0200
Sakari Ailus sakari.ai...@iki.fi wrote:

 Hi Boris,
 
 Thank you for the update.
 
 On Thu, Nov 06, 2014 at 10:56:59AM +0100, Boris Brezillon wrote:
  Rename mediabus formats and move the enum into a separate header file so
  that it can be used by DRM/KMS subsystem without any reference to the V4L2
  subsystem.
  
  Old v4l2_mbus_pixelcode now points to media_bus_format.
  
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
  ---
   include/uapi/linux/Kbuild |   1 +
   include/uapi/linux/media-bus-format.h | 131 
  ++
   include/uapi/linux/v4l2-mediabus.h| 114 +
   3 files changed, 134 insertions(+), 112 deletions(-)
   create mode 100644 include/uapi/linux/media-bus-format.h
  
  diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
  index b70237e..b2c23f8 100644
  --- a/include/uapi/linux/Kbuild
  +++ b/include/uapi/linux/Kbuild
  @@ -414,6 +414,7 @@ header-y += veth.h
   header-y += vfio.h
   header-y += vhost.h
   header-y += videodev2.h
  +header-y += media-bus-format.h
 
 Could you arrange this to the list alphabetically, please?
 
   header-y += virtio_9p.h
   header-y += virtio_balloon.h
   header-y += virtio_blk.h
  diff --git a/include/uapi/linux/media-bus-format.h 
  b/include/uapi/linux/media-bus-format.h
  new file mode 100644
  index 000..251a902
  --- /dev/null
  +++ b/include/uapi/linux/media-bus-format.h
  @@ -0,0 +1,131 @@
  +/*
  + * Media Bus API header
  + *
  + * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +#ifndef __LINUX_MEDIA_BUS_FORMAT_H
  +#define __LINUX_MEDIA_BUS_FORMAT_H
  +
  +/*
  + * These bus formats uniquely identify data formats on the data bus. 
  Format 0
  + * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, 
  where
  + * the data format is fixed. Additionally, 2X8 means that one pixel is
  + * transferred in two 8-bit samples, BE or LE specify in which order 
  those
  + * samples are transferred over the bus: LE means that the least 
  significant
  + * bits are transferred first, BE means that the most significant bits 
  are
  + * transferred first, and PADHI and PADLO define which bits - low or 
  high,
  + * in the incomplete high byte, are filled with padding bits.
  + *
  + * The bus formats are grouped by type, bus_width, bits per component, 
  samples
  + * per pixel and order of subsamples. Numerical values are sorted using 
  generic
  + * numerical sort order (8 thus comes before 10).
  + *
  + * As their value can't change when a new bus format is inserted in the
  + * enumeration, the bus formats are explicitly given a numerical value. 
  The next
  + * free values for each category are listed below, update them when 
  inserting
  + * new pixel codes.
  + */
  +
  +#define MEDIA_BUS_FMT_ENTRY(name, val) \
  +   MEDIA_BUS_FMT_ ## name = val,   \
  +   V4L2_MBUS_FMT_ ## name = val
  +
  +enum media_bus_format {
 
 There's no really a need to keep the definitions inside the enum. It looks a
 little bit confusing to me. That made me realise something I missed
 yesterday.
 
 There's a difference: the enum in C++ is a different thing than in C, and
 the enum type isn't able to contain any other values than those defined in
 the enumeration.
 
 So what I propose is the following. Keep enum v4l2_mbus_pixelcode around,
 including the enum values. Define new values for MEDIA_BUS_* equivalents
 using preprocessor macros, as you've done below. Drop the definition of enum
 media_bus_format, and use u32 (or uint32_t) type for the variables.
 
 This way the enum stays intact for existing C++ applications, and new
 applications will have to use a 32-bit type.
 

Fair enough. If Hans agree I'll rework the series and drop the
media_bus_format enum.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 00/10] [media] Make mediabus format subsystem neutral

2014-11-07 Thread Boris Brezillon
Hello,

This patch series prepares the use of media bus formats outside of
the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
driver where I have to configure my DPI/RGB bus according to the
connected display).

The series first defines MEDIA_BUS_FMT_ macros, and then replace all
references to the v4l2_mbus_pixelcode enum and its values within the
kernel.

Best Regards,

Boris

Changes since v2:
- drop media_bus_format enum and replace its values with pre-processor
  macros

Changes since v1:
- drop patches deprecating v4l2_mbus_pixelcode for user-space users
- put V4L2 legacy format definitions into media-bus-format.h

Boris Brezillon (10):
  [media] Move mediabus format definition to a more standard place
  [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values
  [media] Make use of the new media_bus_format definitions
  [media] i2c: Make use of media_bus_format enum
  [media] pci: Make use of MEDIA_BUS_FMT definitions
  [media] platform: Make use of media_bus_format enum
  [media] usb: Make use of media_bus_format enum
  staging: media: Make use of MEDIA_BUS_FMT_ definitions
  gpu: ipu-v3: Make use of media_bus_format enum
  [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the
kernel

 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   7 +-
 arch/arm/mach-davinci/dm365.c  |   7 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |  66 ++---
 drivers/media/i2c/adv7170.c|  16 +-
 drivers/media/i2c/adv7175.c|  16 +-
 drivers/media/i2c/adv7180.c|   6 +-
 drivers/media/i2c/adv7183.c|   6 +-
 drivers/media/i2c/adv7604.c|  72 ++---
 drivers/media/i2c/adv7842.c|   6 +-
 drivers/media/i2c/ak881x.c |   8 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   6 +-
 drivers/media/i2c/ml86v7667.c  |   6 +-
 drivers/media/i2c/mt9m032.c|   6 +-
 drivers/media/i2c/mt9p031.c|   8 +-
 drivers/media/i2c/mt9t001.c|   8 +-
 drivers/media/i2c/mt9v011.c|   6 +-
 drivers/media/i2c/mt9v032.c|  12 +-
 drivers/media/i2c/noon010pc30.c|  12 +-
 drivers/media/i2c/ov7670.c |  16 +-
 drivers/media/i2c/ov9650.c |  10 +-
 drivers/media/i2c/s5c73m3/s5c73m3.h|   6 +-
 drivers/media/i2c/s5k4ecgx.c   |   4 +-
 drivers/media/i2c/s5k5baf.c|  14 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   8 +-
 drivers/media/i2c/saa6752hs.c  |   6 +-
 drivers/media/i2c/saa7115.c|   2 +-
 drivers/media/i2c/saa717x.c|   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  32 +--
 drivers/media/i2c/soc_camera/imx074.c  |   8 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  14 +-
 drivers/media/i2c/soc_camera/mt9m111.c |  70 ++---
 drivers/media/i2c/soc_camera/mt9t031.c |  10 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  22 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  26 +-
 drivers/media/i2c/soc_camera/ov2640.c  |  54 ++--
 drivers/media/i2c/soc_camera/ov5642.c  |   8 +-
 drivers/media/i2c/soc_camera/ov6650.c  |  58 ++--
 drivers/media/i2c/soc_camera/ov772x.c  |  20 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  40 +--
 drivers/media/i2c/soc_camera/ov9740.c  |  12 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  54 ++--
 drivers/media/i2c/soc_camera/tw9910.c  |  10 +-
 drivers/media/i2c/sr030pc30.c  |  14 +-
 drivers/media/i2c/tvp514x.c|  12 +-
 drivers/media/i2c/tvp5150.c|   6 +-
 drivers/media/i2c/tvp7002.c|  10 +-
 drivers/media/i2c/vs6624.c |  18 +-
 drivers/media/pci/cx18/cx18-av-core.c  |   2 +-
 drivers/media/pci/cx18/cx18-controls.c |   2 +-
 drivers/media/pci/cx18/cx18-ioctl.c|   2 +-
 drivers/media/pci/cx23885/cx23885-video.c  |   2 +-
 drivers/media/pci/ivtv/ivtv-controls.c |   2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c

[PATCH v3 02/10] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed them with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Update the v4l documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 1 file changed, 154 insertions(+), 154 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..18730b9 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -86,7 +86,7 @@
   green and 5-bit blue values padded on the high bit, transferred as 2 
8-bit
   samples per pixel with the most significant bits (padding, red and half 
of
   the green value) transferred first will be named
-  constantV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/constant.
+  constantMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/constant.
   /para
 
   paraThe following tables list existing packed RGB formats./para
@@ -176,8 +176,8 @@
/row
  /thead
  tbody valign=top
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
  dash-ent-24;
@@ -204,8 +204,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
  dash-ent-24;
@@ -232,8 +232,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
  dash-ent-24;
@@ -260,8 +260,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_LE/entry
  entry0x1004/entry
  entry/entry
  dash-ent-24;
@@ -288,8 +288,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-BE
- entryV4L2_MBUS_FMT_BGR565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-BE
+ entryMEDIA_BUS_FMT_BGR565_2X8_BE/entry
  entry0x1005/entry
  entry/entry
  dash-ent-24;
@@ -316,8 +316,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-LE
- entryV4L2_MBUS_FMT_BGR565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-LE
+ entryMEDIA_BUS_FMT_BGR565_2X8_LE/entry
  entry0x1006/entry
  entry/entry
  dash-ent-24;
@@ -344,8 +344,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-BE
- entryV4L2_MBUS_FMT_RGB565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-BE
+ entryMEDIA_BUS_FMT_RGB565_2X8_BE/entry
  entry0x1007/entry
  entry/entry
  dash-ent-24;
@@ -372,8 +372,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-LE
- entryV4L2_MBUS_FMT_RGB565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-LE
+ entryMEDIA_BUS_FMT_RGB565_2X8_LE/entry
  entry0x1008/entry
  entry/entry
  dash-ent-24;
@@ -400,8 +400,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB666-1X18
- entryV4L2_MBUS_FMT_RGB666_1X18/entry
+   row id=MEDIA-BUS-FMT-RGB666-1X18
+ entryMEDIA_BUS_FMT_RGB666_1X18/entry
  entry0x1009/entry
  entry/entry
  dash-ent-14;
@@ -424,8 +424,8 @@
  entrybsubscript1/subscript

[PATCH v3 03/10] [media] Make use of the new media_bus_format definitions

2014-11-07 Thread Boris Brezillon
Replace references to the v4l2_mbus_pixelcode enum with the new
media_bus_format enum in all common headers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/media/v4l2-mediabus.h| 2 +-
 include/media/v4l2-subdev.h  | 2 +-
 include/uapi/linux/v4l2-subdev.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 395c4a9..59d7397 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -98,7 +98,7 @@ static inline void v4l2_fill_pix_format(struct 
v4l2_pix_format *pix_fmt,
 
 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
   const struct v4l2_pix_format *pix_fmt,
-  enum v4l2_mbus_pixelcode code)
+  u32 code)
 {
mbus_fmt-width = pix_fmt-width;
mbus_fmt-height = pix_fmt-height;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d746572..5860292 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -341,7 +341,7 @@ struct v4l2_subdev_video_ops {
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
-enum v4l2_mbus_pixelcode *code);
+u32 *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a619cdd..e0a7e3d 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -68,7 +68,7 @@ struct v4l2_subdev_crop {
  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  */
 struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -81,7 +81,7 @@ struct v4l2_subdev_mbus_code_enum {
  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  */
 struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -109,7 +109,7 @@ struct v4l2_subdev_frame_interval {
  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
  * @pad: pad number, as reported by the media API
  * @index: frame interval index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-07 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/uapi/linux/v4l2-mediabus.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 3d87db7..4f31d0e 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,6 +15,14 @@
 #include linux/videodev2.h
 #include linux/media-bus-format.h
 
+#ifndef __KERNEL__
+
+/*
+ * enum v4l2_mbus_pixelcode and its defintions are now deprecated, and
+ * MEDIA_BUS_FMT_ defintions (defined in media-bus-format.h) should be
+ * used instead.
+ */
+
 #define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
MEDIA_BUS_FMT_ ## name = V4L2_MBUS_FMT_ ## name
 
@@ -102,6 +110,7 @@ enum v4l2_mbus_pixelcode {
 
V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
 };
+#endif /* __KERNEL__ */
 
 /**
  * struct v4l2_mbus_framefmt - frame format on the media bus
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 05/10] [media] pci: Make use of MEDIA_BUS_FMT definitions

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in pci drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/pci/cx18/cx18-av-core.c   | 2 +-
 drivers/media/pci/cx18/cx18-controls.c  | 2 +-
 drivers/media/pci/cx18/cx18-ioctl.c | 2 +-
 drivers/media/pci/cx23885/cx23885-video.c   | 2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c | 2 +-
 drivers/media/pci/saa7134/saa7134-empress.c | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-av-core.c 
b/drivers/media/pci/cx18/cx18-av-core.c
index 2d3afe0..4c6ce21 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, 
struct v4l2_mbus_framefmt
int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
int is_50Hz = !(state-std  V4L2_STD_525_60);
 
-   if (fmt-code != V4L2_MBUS_FMT_FIXED)
+   if (fmt-code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
 
fmt-field = V4L2_FIELD_INTERLACED;
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 282a3d2..4aeb7c6 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 6f2b590..71963db 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
 
mbus_fmt.width = cx-cxhdl.width = w;
mbus_fmt.height = cx-cxhdl.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, mbus_fmt);
return cx18_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f9..091f5db 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -608,7 +608,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-field  = f-fmt.pix.field;
dprintk(2, %s() width=%d height=%d field=%d\n, __func__,
dev-width, dev-height, dev-field);
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
/* s_mbus_fmt overwrites f-fmt.pix.field, restore it */
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 2b0ab26..ccf548c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3e0cb77..4d8ee18 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, 
struct v4l2_format *f
fmt-fmt.pix.width /= 2;
mbus_fmt.width = fmt-fmt.pix.width;
mbus_fmt.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, mbus_fmt);
return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c 
b/drivers/media/pci/saa7134/saa7134-empress.c
index e4ea85f..8b3bb78 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -140,7 +140,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void 
*priv,
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f

[PATCH v3 07/10] [media] usb: Make use of media_bus_format enum

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all usb drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++--
 drivers/media/usb/em28xx/em28xx-camera.c  | 2 +-
 drivers/media/usb/go7007/go7007-v4l2.c| 2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 459bb0e..95653ba 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1878,7 +1878,7 @@ static int cx231xx_s_video_encoding(struct 
cx2341x_handler *cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev-sd_cx25840, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 3b3ada6..989d527 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -967,7 +967,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-height = f-fmt.pix.height;
dev-format = fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
 
@@ -1012,7 +1012,7 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id norm)
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
memset(mbus_fmt, 0, sizeof(mbus_fmt));
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = dev-width;
mbus_fmt.height = dev-height;
call_all(dev, video, s_mbus_fmt, mbus_fmt);
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index 6d2ea9a..38cf6c8 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -430,7 +430,7 @@ int em28xx_init_camera(struct em28xx *dev)
break;
}
 
-   fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
+   fmt.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640;
fmt.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, fmt);
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c 
b/drivers/media/usb/go7007/go7007-v4l2.c
index ec799b4..d6bf982 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct 
v4l2_format *fmt, int try)
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt;
 
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt-fmt.pix.width : width;
mbus_fmt.height = height;
go-encoder_h_halve = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 9623b62..2fd9b5e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
memset(fmt, 0, sizeof(fmt));
fmt.width = hdw-res_hor_val;
fmt.height = hdw-res_ver_val;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, subdev v4l2 set_size(%dx%d),
   fmt.width, fmt.height);
v4l2_device_call_all(hdw-v4l2_dev, 0, video, s_mbus_fmt, 
fmt);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 08/10] staging: media: Make use of MEDIA_BUS_FMT_ definitions

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all media drivers residing in staging.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  18 ++--
 .../staging/media/davinci_vpfe/dm365_ipipe_hw.c|  26 +++---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 100 ++---
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  90 +--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  98 ++--
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  18 ++--
 drivers/staging/media/omap4iss/iss_csi2.c  |  62 ++---
 drivers/staging/media/omap4iss/iss_ipipe.c |  16 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  28 +++---
 drivers/staging/media/omap4iss/iss_resizer.c   |  26 +++---
 drivers/staging/media/omap4iss/iss_video.c |  78 
 drivers/staging/media/omap4iss/iss_video.h |  10 +--
 12 files changed, 285 insertions(+), 285 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index bdc7f00..704fa20 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -37,15 +37,15 @@
 
 /* ipipe input format's */
 static const unsigned int ipipe_input_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_SGRBG12_1X12,
-   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
-   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
+   MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
 };
 
 /* ipipe output format's */
 static const unsigned int ipipe_output_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
 };
 
 static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
@@ -1457,7 +1457,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use SBGGR10 as default */
if (i = ARRAY_SIZE(ipipe_input_fmts))
-   fmt-code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   fmt-code = MEDIA_BUS_FMT_SGRBG12_1X12;
} else if (pad == IPIPE_PAD_SOURCE) {
for (i = 0; i  ARRAY_SIZE(ipipe_output_fmts); i++)
if (fmt-code == ipipe_output_fmts[i])
@@ -1465,7 +1465,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use UYVY as default */
if (i = ARRAY_SIZE(ipipe_output_fmts))
-   fmt-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   fmt-code = MEDIA_BUS_FMT_UYVY8_2X8;
}
 
fmt-width = clamp_t(u32, fmt-width, MIN_OUT_HEIGHT, max_out_width);
@@ -1642,7 +1642,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SINK;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
@@ -1650,7 +1650,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SOURCE;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
+   format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index b2daf5e..6461de1 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -196,12 +196,12 @@ ipipe_setup_resizer(void *__iomem rsz_base, struct 
resizer_params *params)
rsz_set_rsz_regs(rsz_base, RSZ_B, params);
 }
 
-static u32 ipipe_get_color_pat(enum v4l2_mbus_pixelcode pix)
+static u32 ipipe_get_color_pat(u32 pix)
 {
switch (pix) {
-   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
return ipipe_sgrbg_pattern;
 
default:
@@ -211,23 +211,23 @@ static u32 ipipe_get_color_pat(enum

[PATCH v3 09/10] gpu: ipu-v3: Make use of media_bus_format enum

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in the ipu-v3 driver.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 66 ++--
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index d6f56471..752cdd2 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -227,83 +227,83 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, 
u32 pixel_clk,
 static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 {
switch (mbus_code) {
-   case V4L2_MBUS_FMT_BGR565_2X8_BE:
-   case V4L2_MBUS_FMT_BGR565_2X8_LE:
-   case V4L2_MBUS_FMT_RGB565_2X8_BE:
-   case V4L2_MBUS_FMT_RGB565_2X8_LE:
+   case MEDIA_BUS_FMT_BGR565_2X8_BE:
+   case MEDIA_BUS_FMT_BGR565_2X8_LE:
+   case MEDIA_BUS_FMT_RGB565_2X8_BE:
+   case MEDIA_BUS_FMT_RGB565_2X8_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
cfg-mipi_dt = MIPI_DT_RGB565;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB444;
cfg-mipi_dt = MIPI_DT_RGB444;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB555;
cfg-mipi_dt = MIPI_DT_RGB555;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_YUYV8_2X8:
+   case MEDIA_BUS_FMT_YUYV8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_YUYV8_1X16:
+   case MEDIA_BUS_FMT_YUYV8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_SBGGR8_1X8:
-   case V4L2_MBUS_FMT_SGBRG8_1X8:
-   case V4L2_MBUS_FMT_SGRBG8_1X8:
-   case V4L2_MBUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW8;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+   case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW10;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_1X10:
-   case V4L2_MBUS_FMT_SGBRG10_1X10:
-   case V4L2_MBUS_FMT_SGRBG10_1X10:
-   case V4L2_MBUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
cfg-data_fmt

[PATCH v3 04/10] [media] i2c: Make use of media_bus_format enum

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definitions to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in i2c drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/i2c/adv7170.c   | 16 +++
 drivers/media/i2c/adv7175.c   | 16 +++
 drivers/media/i2c/adv7180.c   |  6 +--
 drivers/media/i2c/adv7183.c   |  6 +--
 drivers/media/i2c/adv7604.c   | 72 +++
 drivers/media/i2c/adv7842.c   |  6 +--
 drivers/media/i2c/ak881x.c|  8 ++--
 drivers/media/i2c/cx25840/cx25840-core.c  |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c|  6 +--
 drivers/media/i2c/ml86v7667.c |  6 +--
 drivers/media/i2c/mt9m032.c   |  6 +--
 drivers/media/i2c/mt9p031.c   |  8 ++--
 drivers/media/i2c/mt9t001.c   |  8 ++--
 drivers/media/i2c/mt9v011.c   |  6 +--
 drivers/media/i2c/mt9v032.c   | 12 +++---
 drivers/media/i2c/noon010pc30.c   | 12 +++---
 drivers/media/i2c/ov7670.c| 16 +++
 drivers/media/i2c/ov9650.c| 10 ++---
 drivers/media/i2c/s5c73m3/s5c73m3.h   |  6 +--
 drivers/media/i2c/s5k4ecgx.c  |  4 +-
 drivers/media/i2c/s5k5baf.c   | 14 +++---
 drivers/media/i2c/s5k6a3.c|  2 +-
 drivers/media/i2c/s5k6aa.c|  8 ++--
 drivers/media/i2c/saa6752hs.c |  6 +--
 drivers/media/i2c/saa7115.c   |  2 +-
 drivers/media/i2c/saa717x.c   |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 32 +++---
 drivers/media/i2c/soc_camera/imx074.c |  8 ++--
 drivers/media/i2c/soc_camera/mt9m001.c| 14 +++---
 drivers/media/i2c/soc_camera/mt9m111.c| 70 +++---
 drivers/media/i2c/soc_camera/mt9t031.c| 10 ++---
 drivers/media/i2c/soc_camera/mt9t112.c| 22 +-
 drivers/media/i2c/soc_camera/mt9v022.c| 26 +--
 drivers/media/i2c/soc_camera/ov2640.c | 54 +++
 drivers/media/i2c/soc_camera/ov5642.c |  8 ++--
 drivers/media/i2c/soc_camera/ov6650.c | 58 -
 drivers/media/i2c/soc_camera/ov772x.c | 20 -
 drivers/media/i2c/soc_camera/ov9640.c | 40 -
 drivers/media/i2c/soc_camera/ov9740.c | 12 +++---
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 54 +++
 drivers/media/i2c/soc_camera/tw9910.c | 10 ++---
 drivers/media/i2c/sr030pc30.c | 14 +++---
 drivers/media/i2c/tvp514x.c   | 12 +++---
 drivers/media/i2c/tvp5150.c   |  6 +--
 drivers/media/i2c/tvp7002.c   | 10 ++---
 drivers/media/i2c/vs6624.c| 18 
 46 files changed, 382 insertions(+), 382 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index 04bb297..40a1a95 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { pass_through, play_back };
 
-static enum v4l2_mbus_pixelcode adv7170_codes[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_UYVY8_1X16,
+static u32 adv7170_codes[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_1X16,
 };
 
 /* --- */
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
 }
 
 static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-   enum v4l2_mbus_pixelcode *code)
+   u32 *code)
 {
if (index = ARRAY_SIZE(adv7170_codes))
return -EINVAL;
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd,
u8 val = adv7170_read(sd, 0x7);
 
if ((val  0x40) == (1  6))
-   mf-code = V4L2_MBUS_FMT_UYVY8_1X16;
+   mf-code = MEDIA_BUS_FMT_UYVY8_1X16;
else
-   mf-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   mf-code = MEDIA_BUS_FMT_UYVY8_2X8;
 
mf-colorspace  = V4L2_COLORSPACE_SMPTE170M;
mf-width   = 0;
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
int ret;
 
switch (mf-code) {
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
val = ~0x40;
break;
 
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
val |= 0x40;
break;
 
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index b88f3b3..d220af5 100644
--- a/drivers/media/i2c/adv7175.c
+++ b/drivers/media/i2c/adv7175.c
@@ -60,9 +60,9 @@ static inline struct adv7175

[PATCH v3 06/10] [media] platform: Make use of media_bus_format enum

2014-11-07 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all platform drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   7 +-
 arch/arm/mach-davinci/dm365.c  |   7 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/media/platform/blackfin/bfin_capture.c |  14 +--
 drivers/media/platform/davinci/vpbe.c  |   2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |   4 +-
 drivers/media/platform/exynos-gsc/gsc-core.c   |   8 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |   2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-core.h  |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  16 +--
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |  26 ++---
 drivers/media/platform/exynos4-is/fimc-lite.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-reg.c   |  14 +--
 drivers/media/platform/exynos4-is/mipi-csis.c  |  14 +--
 drivers/media/platform/marvell-ccic/mcam-core.c|  21 ++--
 drivers/media/platform/marvell-ccic/mcam-core.h|   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  | 112 ++---
 drivers/media/platform/omap3isp/ispccp2.c  |  18 ++--
 drivers/media/platform/omap3isp/ispcsi2.c  |  42 
 drivers/media/platform/omap3isp/isppreview.c   |  60 ++-
 drivers/media/platform/omap3isp/ispresizer.c   |  19 ++--
 drivers/media/platform/omap3isp/ispvideo.c |  95 +
 drivers/media/platform/omap3isp/ispvideo.h |  10 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  10 +-
 drivers/media/platform/s3c-camif/camif-regs.c  |   8 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c   |   2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c|   2 +-
 drivers/media/platform/sh_vou.c|   8 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |  22 ++--
 drivers/media/platform/soc_camera/mx2_camera.c |  26 +++--
 drivers/media/platform/soc_camera/mx3_camera.c |   6 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |  36 +++
 drivers/media/platform/soc_camera/pxa_camera.c |  16 +--
 drivers/media/platform/soc_camera/rcar_vin.c   |  14 +--
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  20 ++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  38 +++
 drivers/media/platform/soc_camera/soc_camera.c |   2 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |  78 +++---
 drivers/media/platform/via-camera.c|   8 +-
 drivers/media/platform/vsp1/vsp1_bru.c |  14 +--
 drivers/media/platform/vsp1/vsp1_hsit.c|  12 +--
 drivers/media/platform/vsp1/vsp1_lif.c |  10 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  14 +--
 drivers/media/platform/vsp1/vsp1_rwpf.c|  10 +-
 drivers/media/platform/vsp1/vsp1_sru.c |  12 +--
 drivers/media/platform/vsp1/vsp1_uds.c |  10 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  42 
 include/media/davinci/vpbe.h   |   2 +-
 include/media/davinci/vpbe_venc.h  |   5 +-
 include/media/exynos-fimc.h|   2 +-
 include/media/soc_camera.h |   2 +-
 include/media/soc_mediabus.h   |   6 +-
 59 files changed, 483 insertions(+), 495 deletions(-)

diff --git a/Documentation/video4linux/soc-camera.txt 
b/Documentation/video4linux/soc-camera.txt
index daa9e2a..84f41cf 100644
--- a/Documentation/video4linux/soc-camera.txt
+++ b/Documentation/video4linux/soc-camera.txt
@@ -151,7 +151,7 @@ they are transferred over a media bus. Soc-camera provides 
support to
 conveniently manage these formats. A table of standard transformations is
 maintained by soc-camera core, which describes, what FOURCC pixel format will
 be obtained, if a media-bus pixel format is stored in memory according to
-certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
+certain rules. E.g. if MEDIA_BUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
 sample and stored in memory in the little-endian order with no gaps between
 bytes, data in memory will represent the V4L2_PIX_FMT_YUYV FOURCC format. These
 standard transformations will be used by soc-camera

Re: [PATCH v3 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-07 Thread Boris Brezillon
On Fri, 07 Nov 2014 15:47:41 +0100
Hans Verkuil hverk...@xs4all.nl wrote:

 Nitpicks:
 
 On 11/07/14 15:07, Boris Brezillon wrote:
  Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
  users don't have access to these definitions.
  
  We have to keep this definition for user-space users even though they're
  encouraged to move to the new media_bus_format enum.
  
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  ---
   include/uapi/linux/v4l2-mediabus.h | 9 +
   1 file changed, 9 insertions(+)
  
  diff --git a/include/uapi/linux/v4l2-mediabus.h 
  b/include/uapi/linux/v4l2-mediabus.h
  index 3d87db7..4f31d0e 100644
  --- a/include/uapi/linux/v4l2-mediabus.h
  +++ b/include/uapi/linux/v4l2-mediabus.h
  @@ -15,6 +15,14 @@
   #include linux/videodev2.h
   #include linux/media-bus-format.h
   
  +#ifndef __KERNEL__
  +
  +/*
  + * enum v4l2_mbus_pixelcode and its defintions are now deprecated, and
 
 defintions - definitions
 
  + * MEDIA_BUS_FMT_ defintions (defined in media-bus-format.h) should be
 
 and again...
 
  + * used instead.
 
 I would also add something like this:
 
 New defines should only be added to media-bus-format.h. The 
 v4l2_mbus_pixelcode
 enum is frozen.

I'll fix those typos and add this sentence.

 
  + */
  +
   #define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
  MEDIA_BUS_FMT_ ## name = V4L2_MBUS_FMT_ ## name
   
  @@ -102,6 +110,7 @@ enum v4l2_mbus_pixelcode {
   
  V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
   };
  +#endif /* __KERNEL__ */
   
   /**
* struct v4l2_mbus_framefmt - frame format on the media bus
  
 
 Can you move this struct forward to before the v4l2_mbus_pixelcode enum? That 
 way
 the obsolete code is at the end of the header. People might miss this struct
 otherwise.

Sure.

Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 01/10] [media] Move mediabus format definition to a more standard place

2014-11-07 Thread Boris Brezillon
Hi Sakari,

On Fri, 7 Nov 2014 17:24:16 +0200
Sakari Ailus sakari.ai...@iki.fi wrote:

 Hi Boris,
 
 On Fri, Nov 07, 2014 at 03:07:40PM +0100, Boris Brezillon wrote:
  Define MEDIA_BUS_FMT macros (re-using the values defined in the
  v4l2_mbus_pixelcode enum) into a separate header file so that they can be
  used from the DRM/KMS subsystem without any reference to the V4L2
  subsystem.
  
  Then set V4L2_MBUS_FMT definitions to the MEDIA_BUS_FMT values using the
  V4L2_MBUS_FROM_MEDIA_BUS_FMT macro.
  
  Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  ---
   include/uapi/linux/Kbuild |   1 +
   include/uapi/linux/media-bus-format.h | 125 +++
   include/uapi/linux/v4l2-mediabus.h| 184 
  +++---
   3 files changed, 206 insertions(+), 104 deletions(-)
   create mode 100644 include/uapi/linux/media-bus-format.h
  
  diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
  index b70237e..ed39ac8 100644
  --- a/include/uapi/linux/Kbuild
  +++ b/include/uapi/linux/Kbuild
  @@ -241,6 +241,7 @@ header-y += map_to_7segment.h
   header-y += matroxfb.h
   header-y += mdio.h
   header-y += media.h
  +header-y += media-bus-format.h
   header-y += mei.h
   header-y += memfd.h
   header-y += mempolicy.h
  diff --git a/include/uapi/linux/media-bus-format.h 
  b/include/uapi/linux/media-bus-format.h
  new file mode 100644
  index 000..23b4090

[...]

  +/* Vendor specific formats - next is   0x5002 */
  +
  +/* S5C73M3 sensor specific interleaved UYVY and JPEG */
  +#define MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X80x5001
  +
  +/* HSV - next is   0x6002 */
  +#define MEDIA_BUS_FMT_AHSV_1X320x6001
  +
  +#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
  diff --git a/include/uapi/linux/v4l2-mediabus.h 
  b/include/uapi/linux/v4l2-mediabus.h
  index 1445e85..3d87db7 100644
  --- a/include/uapi/linux/v4l2-mediabus.h
  +++ b/include/uapi/linux/v4l2-mediabus.h
  @@ -13,118 +13,94 @@
   
   #include linux/types.h
   #include linux/videodev2.h
  +#include linux/media-bus-format.h
 
 Alphabetical order, please.

I'll fix that.

 
   
  -/*
  - * These pixel codes uniquely identify data formats on the media bus. 
  Mostly
  - * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
  - * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where 
  the
  - * data format is fixed. Additionally, 2X8 means that one pixel is 
  transferred
  - * in two 8-bit samples, BE or LE specify in which order those samples 
  are
  - * transferred over the bus: LE means that the least significant bits are
  - * transferred first, BE means that the most significant bits are 
  transferred
  - * first, and PADHI and PADLO define which bits - low or high, in the
  - * incomplete high byte, are filled with padding bits.
  - *
  - * The pixel codes are grouped by type, bus_width, bits per component, 
  samples
  - * per pixel and order of subsamples. Numerical values are sorted using 
  generic
  - * numerical sort order (8 thus comes before 10).
  - *
  - * As their value can't change when a new pixel code is inserted in the
  - * enumeration, the pixel codes are explicitly given a numerical value. 
  The next
  - * free values for each category are listed below, update them when 
  inserting
  - * new pixel codes.
  - */
  -enum v4l2_mbus_pixelcode {
  -   V4L2_MBUS_FMT_FIXED = 0x0001,
  +#define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
  +   MEDIA_BUS_FMT_ ## name = V4L2_MBUS_FMT_ ## name
 
 Could you add a comment telling these values should no longer be changed?

I'll add this comment in patch 10 as suggested by Hans.

Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-07 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/uapi/linux/v4l2-mediabus.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index d712df8..3358e86 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,6 +15,17 @@
 #include linux/types.h
 #include linux/videodev2.h
 
+#ifndef __KERNEL__
+
+/*
+ * enum v4l2_mbus_pixelcode and its definitions are now deprecated, and
+ * MEDIA_BUS_FMT_ definitions (defined in media-bus-format.h) should be
+ * used instead.
+ *
+ * New defines should only be added to media-bus-format.h. The
+ * v4l2_mbus_pixelcode enum is frozen.
+ */
+
 #define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
MEDIA_BUS_FMT_ ## name = V4L2_MBUS_FMT_ ## name
 
@@ -102,6 +113,7 @@ enum v4l2_mbus_pixelcode {
 
V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
 };
+#endif /* __KERNEL__ */
 
 /**
  * struct v4l2_mbus_framefmt - frame format on the media bus
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 01/10] [media] Move mediabus format definition to a more standard place

2014-11-07 Thread Boris Brezillon
Define MEDIA_BUS_FMT macros (re-using the values defined in the
v4l2_mbus_pixelcode enum) into a separate header file so that they can be
used from the DRM/KMS subsystem without any reference to the V4L2
subsystem.

Then set V4L2_MBUS_FMT definitions to the MEDIA_BUS_FMT values using the
V4L2_MBUS_FROM_MEDIA_BUS_FMT macro.

Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/media-bus-format.h | 125 +++
 include/uapi/linux/v4l2-mediabus.h| 184 +++---
 3 files changed, 206 insertions(+), 104 deletions(-)
 create mode 100644 include/uapi/linux/media-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e..ed39ac8 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -241,6 +241,7 @@ header-y += map_to_7segment.h
 header-y += matroxfb.h
 header-y += mdio.h
 header-y += media.h
+header-y += media-bus-format.h
 header-y += mei.h
 header-y += memfd.h
 header-y += mempolicy.h
diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
new file mode 100644
index 000..23b4090
--- /dev/null
+++ b/include/uapi/linux/media-bus-format.h
@@ -0,0 +1,125 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MEDIA_BUS_FORMAT_H
+#define __LINUX_MEDIA_BUS_FORMAT_H
+
+/*
+ * These bus formats uniquely identify data formats on the data bus. Format 0
+ * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where
+ * the data format is fixed. Additionally, 2X8 means that one pixel is
+ * transferred in two 8-bit samples, BE or LE specify in which order those
+ * samples are transferred over the bus: LE means that the least significant
+ * bits are transferred first, BE means that the most significant bits are
+ * transferred first, and PADHI and PADLO define which bits - low or high,
+ * in the incomplete high byte, are filled with padding bits.
+ *
+ * The bus formats are grouped by type, bus_width, bits per component, samples
+ * per pixel and order of subsamples. Numerical values are sorted using generic
+ * numerical sort order (8 thus comes before 10).
+ *
+ * As their value can't change when a new bus format is inserted in the
+ * enumeration, the bus formats are explicitly given a numerical value. The 
next
+ * free values for each category are listed below, update them when inserting
+ * new pixel codes.
+ */
+
+#define MEDIA_BUS_FMT_FIXED0x0001
+
+/* RGB - next is   0x100e */
+#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE  0x1001
+#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE  0x1002
+#define MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE  0x1003
+#define MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE  0x1004
+#define MEDIA_BUS_FMT_BGR565_2X8_BE0x1005
+#define MEDIA_BUS_FMT_BGR565_2X8_LE0x1006
+#define MEDIA_BUS_FMT_RGB565_2X8_BE0x1007
+#define MEDIA_BUS_FMT_RGB565_2X8_LE0x1008
+#define MEDIA_BUS_FMT_RGB666_1X18  0x1009
+#define MEDIA_BUS_FMT_RGB888_1X24  0x100a
+#define MEDIA_BUS_FMT_RGB888_2X12_BE   0x100b
+#define MEDIA_BUS_FMT_RGB888_2X12_LE   0x100c
+#define MEDIA_BUS_FMT_ARGB_1X320x100d
+
+/* YUV (including grey) - next is  0x2024 */
+#define MEDIA_BUS_FMT_Y8_1X8   0x2001
+#define MEDIA_BUS_FMT_UV8_1X8  0x2015
+#define MEDIA_BUS_FMT_UYVY8_1_5X8  0x2002
+#define MEDIA_BUS_FMT_VYUY8_1_5X8  0x2003
+#define MEDIA_BUS_FMT_YUYV8_1_5X8  0x2004
+#define MEDIA_BUS_FMT_YVYU8_1_5X8  0x2005
+#define MEDIA_BUS_FMT_UYVY8_2X80x2006
+#define MEDIA_BUS_FMT_VYUY8_2X80x2007
+#define MEDIA_BUS_FMT_YUYV8_2X80x2008
+#define MEDIA_BUS_FMT_YVYU8_2X80x2009
+#define MEDIA_BUS_FMT_Y10_1X10 0x200a
+#define MEDIA_BUS_FMT_UYVY10_2X10  0x2018
+#define MEDIA_BUS_FMT_VYUY10_2X10  0x2019
+#define MEDIA_BUS_FMT_YUYV10_2X10  0x200b
+#define MEDIA_BUS_FMT_YVYU10_2X10  0x200c
+#define MEDIA_BUS_FMT_Y12_1X12 0x2013
+#define MEDIA_BUS_FMT_UYVY8_1X16   0x200f
+#define MEDIA_BUS_FMT_VYUY8_1X16   0x2010
+#define MEDIA_BUS_FMT_YUYV8_1X16   0x2011
+#define MEDIA_BUS_FMT_YVYU8_1X16   0x2012
+#define MEDIA_BUS_FMT_YDYUYDYV8_1X16   0x2014
+#define MEDIA_BUS_FMT_UYVY10_1X20  0x201a
+#define MEDIA_BUS_FMT_VYUY10_1X20

Re: [PATCH v4 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-07 Thread Boris Brezillon
On Sat, 08 Nov 2014 00:47:25 +0200
Sakari Ailus sakari.ai...@iki.fi wrote:

 Hi Boris,
 
 Boris Brezillon wrote:
  @@ -102,6 +113,7 @@ enum v4l2_mbus_pixelcode {
   
  V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
   };
  +#endif /* __KERNEL__ */
   
   /**
* struct v4l2_mbus_framefmt - frame format on the media bus
 
 Was it intended to be this way, or did I miss something? I'd put this to
 beginning of the file, as Hans suggested.

Oops, I forgot to move the struct.

 
 With this matter sorted out, for the set:
 
 Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
 



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-08 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/uapi/linux/v4l2-mediabus.h | 45 --
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index d712df8..5c9410d 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,6 +15,33 @@
 #include linux/types.h
 #include linux/videodev2.h
 
+/**
+ * struct v4l2_mbus_framefmt - frame format on the media bus
+ * @width: frame width
+ * @height:frame height
+ * @code:  data format code (from enum v4l2_mbus_pixelcode)
+ * @field: used interlacing type (from enum v4l2_field)
+ * @colorspace:colorspace of the data (from enum v4l2_colorspace)
+ */
+struct v4l2_mbus_framefmt {
+   __u32   width;
+   __u32   height;
+   __u32   code;
+   __u32   field;
+   __u32   colorspace;
+   __u32   reserved[7];
+};
+
+#ifndef __KERNEL__
+/*
+ * enum v4l2_mbus_pixelcode and its definitions are now deprecated, and
+ * MEDIA_BUS_FMT_ definitions (defined in media-bus-format.h) should be
+ * used instead.
+ *
+ * New defines should only be added to media-bus-format.h. The
+ * v4l2_mbus_pixelcode enum is frozen.
+ */
+
 #define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
MEDIA_BUS_FMT_ ## name = V4L2_MBUS_FMT_ ## name
 
@@ -102,22 +129,6 @@ enum v4l2_mbus_pixelcode {
 
V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
 };
-
-/**
- * struct v4l2_mbus_framefmt - frame format on the media bus
- * @width: frame width
- * @height:frame height
- * @code:  data format code (from enum v4l2_mbus_pixelcode)
- * @field: used interlacing type (from enum v4l2_field)
- * @colorspace:colorspace of the data (from enum v4l2_colorspace)
- */
-struct v4l2_mbus_framefmt {
-   __u32   width;
-   __u32   height;
-   __u32   code;
-   __u32   field;
-   __u32   colorspace;
-   __u32   reserved[7];
-};
+#endif /* __KERNEL__ */
 
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 09/10] gpu: ipu-v3: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in the ipu-v3 driver.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 66 ++--
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index d6f56471..752cdd2 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -227,83 +227,83 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, 
u32 pixel_clk,
 static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 {
switch (mbus_code) {
-   case V4L2_MBUS_FMT_BGR565_2X8_BE:
-   case V4L2_MBUS_FMT_BGR565_2X8_LE:
-   case V4L2_MBUS_FMT_RGB565_2X8_BE:
-   case V4L2_MBUS_FMT_RGB565_2X8_LE:
+   case MEDIA_BUS_FMT_BGR565_2X8_BE:
+   case MEDIA_BUS_FMT_BGR565_2X8_LE:
+   case MEDIA_BUS_FMT_RGB565_2X8_BE:
+   case MEDIA_BUS_FMT_RGB565_2X8_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
cfg-mipi_dt = MIPI_DT_RGB565;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB444;
cfg-mipi_dt = MIPI_DT_RGB444;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB555;
cfg-mipi_dt = MIPI_DT_RGB555;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_YUYV8_2X8:
+   case MEDIA_BUS_FMT_YUYV8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_YUYV8_1X16:
+   case MEDIA_BUS_FMT_YUYV8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_SBGGR8_1X8:
-   case V4L2_MBUS_FMT_SGBRG8_1X8:
-   case V4L2_MBUS_FMT_SGRBG8_1X8:
-   case V4L2_MBUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW8;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+   case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW10;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_1X10:
-   case V4L2_MBUS_FMT_SGBRG10_1X10:
-   case V4L2_MBUS_FMT_SGRBG10_1X10:
-   case V4L2_MBUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case

[PATCH v6 04/10] [media] i2c: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definitions to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in i2c drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/adv7170.c   | 16 +++
 drivers/media/i2c/adv7175.c   | 16 +++
 drivers/media/i2c/adv7180.c   |  6 +--
 drivers/media/i2c/adv7183.c   |  6 +--
 drivers/media/i2c/adv7604.c   | 72 +++
 drivers/media/i2c/adv7842.c   |  6 +--
 drivers/media/i2c/ak881x.c|  8 ++--
 drivers/media/i2c/cx25840/cx25840-core.c  |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c|  6 +--
 drivers/media/i2c/ml86v7667.c |  6 +--
 drivers/media/i2c/mt9m032.c   |  6 +--
 drivers/media/i2c/mt9p031.c   |  8 ++--
 drivers/media/i2c/mt9t001.c   |  8 ++--
 drivers/media/i2c/mt9v011.c   |  6 +--
 drivers/media/i2c/mt9v032.c   | 12 +++---
 drivers/media/i2c/noon010pc30.c   | 12 +++---
 drivers/media/i2c/ov7670.c| 16 +++
 drivers/media/i2c/ov9650.c| 10 ++---
 drivers/media/i2c/s5c73m3/s5c73m3.h   |  6 +--
 drivers/media/i2c/s5k4ecgx.c  |  4 +-
 drivers/media/i2c/s5k5baf.c   | 14 +++---
 drivers/media/i2c/s5k6a3.c|  2 +-
 drivers/media/i2c/s5k6aa.c|  8 ++--
 drivers/media/i2c/saa6752hs.c |  6 +--
 drivers/media/i2c/saa7115.c   |  2 +-
 drivers/media/i2c/saa717x.c   |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 32 +++---
 drivers/media/i2c/soc_camera/imx074.c |  8 ++--
 drivers/media/i2c/soc_camera/mt9m001.c| 14 +++---
 drivers/media/i2c/soc_camera/mt9m111.c| 70 +++---
 drivers/media/i2c/soc_camera/mt9t031.c| 10 ++---
 drivers/media/i2c/soc_camera/mt9t112.c| 22 +-
 drivers/media/i2c/soc_camera/mt9v022.c| 26 +--
 drivers/media/i2c/soc_camera/ov2640.c | 54 +++
 drivers/media/i2c/soc_camera/ov5642.c |  8 ++--
 drivers/media/i2c/soc_camera/ov6650.c | 58 -
 drivers/media/i2c/soc_camera/ov772x.c | 20 -
 drivers/media/i2c/soc_camera/ov9640.c | 40 -
 drivers/media/i2c/soc_camera/ov9740.c | 12 +++---
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 54 +++
 drivers/media/i2c/soc_camera/tw9910.c | 10 ++---
 drivers/media/i2c/sr030pc30.c | 14 +++---
 drivers/media/i2c/tvp514x.c   | 12 +++---
 drivers/media/i2c/tvp5150.c   |  6 +--
 drivers/media/i2c/tvp7002.c   | 10 ++---
 drivers/media/i2c/vs6624.c| 18 
 46 files changed, 382 insertions(+), 382 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index 04bb297..40a1a95 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { pass_through, play_back };
 
-static enum v4l2_mbus_pixelcode adv7170_codes[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_UYVY8_1X16,
+static u32 adv7170_codes[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_1X16,
 };
 
 /* --- */
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
 }
 
 static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-   enum v4l2_mbus_pixelcode *code)
+   u32 *code)
 {
if (index = ARRAY_SIZE(adv7170_codes))
return -EINVAL;
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd,
u8 val = adv7170_read(sd, 0x7);
 
if ((val  0x40) == (1  6))
-   mf-code = V4L2_MBUS_FMT_UYVY8_1X16;
+   mf-code = MEDIA_BUS_FMT_UYVY8_1X16;
else
-   mf-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   mf-code = MEDIA_BUS_FMT_UYVY8_2X8;
 
mf-colorspace  = V4L2_COLORSPACE_SMPTE170M;
mf-width   = 0;
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
int ret;
 
switch (mf-code) {
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
val = ~0x40;
break;
 
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
val |= 0x40;
break;
 
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index b88f3b3..d220af5 100644
--- a/drivers/media

[PATCH v6 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-10 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/uapi/linux/v4l2-mediabus.h | 45 --
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index d712df8..5c9410d 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,6 +15,33 @@
 #include linux/types.h
 #include linux/videodev2.h
 
+/**
+ * struct v4l2_mbus_framefmt - frame format on the media bus
+ * @width: frame width
+ * @height:frame height
+ * @code:  data format code (from enum v4l2_mbus_pixelcode)
+ * @field: used interlacing type (from enum v4l2_field)
+ * @colorspace:colorspace of the data (from enum v4l2_colorspace)
+ */
+struct v4l2_mbus_framefmt {
+   __u32   width;
+   __u32   height;
+   __u32   code;
+   __u32   field;
+   __u32   colorspace;
+   __u32   reserved[7];
+};
+
+#ifndef __KERNEL__
+/*
+ * enum v4l2_mbus_pixelcode and its definitions are now deprecated, and
+ * MEDIA_BUS_FMT_ definitions (defined in media-bus-format.h) should be
+ * used instead.
+ *
+ * New defines should only be added to media-bus-format.h. The
+ * v4l2_mbus_pixelcode enum is frozen.
+ */
+
 #define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
MEDIA_BUS_FMT_ ## name = V4L2_MBUS_FMT_ ## name
 
@@ -102,22 +129,6 @@ enum v4l2_mbus_pixelcode {
 
V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
 };
-
-/**
- * struct v4l2_mbus_framefmt - frame format on the media bus
- * @width: frame width
- * @height:frame height
- * @code:  data format code (from enum v4l2_mbus_pixelcode)
- * @field: used interlacing type (from enum v4l2_field)
- * @colorspace:colorspace of the data (from enum v4l2_colorspace)
- */
-struct v4l2_mbus_framefmt {
-   __u32   width;
-   __u32   height;
-   __u32   code;
-   __u32   field;
-   __u32   colorspace;
-   __u32   reserved[7];
-};
+#endif /* __KERNEL__ */
 
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 05/10] [media] pci: Make use of MEDIA_BUS_FMT definitions

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in pci drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/pci/cx18/cx18-av-core.c   | 2 +-
 drivers/media/pci/cx18/cx18-controls.c  | 2 +-
 drivers/media/pci/cx18/cx18-ioctl.c | 2 +-
 drivers/media/pci/cx23885/cx23885-video.c   | 2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c | 2 +-
 drivers/media/pci/saa7134/saa7134-empress.c | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-av-core.c 
b/drivers/media/pci/cx18/cx18-av-core.c
index 2d3afe0..4c6ce21 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, 
struct v4l2_mbus_framefmt
int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
int is_50Hz = !(state-std  V4L2_STD_525_60);
 
-   if (fmt-code != V4L2_MBUS_FMT_FIXED)
+   if (fmt-code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
 
fmt-field = V4L2_FIELD_INTERLACED;
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 282a3d2..4aeb7c6 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 6f2b590..71963db 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
 
mbus_fmt.width = cx-cxhdl.width = w;
mbus_fmt.height = cx-cxhdl.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, mbus_fmt);
return cx18_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f9..091f5db 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -608,7 +608,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-field  = f-fmt.pix.field;
dprintk(2, %s() width=%d height=%d field=%d\n, __func__,
dev-width, dev-height, dev-field);
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
/* s_mbus_fmt overwrites f-fmt.pix.field, restore it */
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 2b0ab26..ccf548c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3e0cb77..4d8ee18 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, 
struct v4l2_format *f
fmt-fmt.pix.width /= 2;
mbus_fmt.width = fmt-fmt.pix.width;
mbus_fmt.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, mbus_fmt);
return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c 
b/drivers/media/pci/saa7134/saa7134-empress.c
index e4ea85f..8b3bb78 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -140,7 +140,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void 
*priv,
struct saa7134_dev *dev = video_drvdata

[PATCH v6 02/10] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed them with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Update the v4l documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 1 file changed, 154 insertions(+), 154 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..18730b9 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -86,7 +86,7 @@
   green and 5-bit blue values padded on the high bit, transferred as 2 
8-bit
   samples per pixel with the most significant bits (padding, red and half 
of
   the green value) transferred first will be named
-  constantV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/constant.
+  constantMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/constant.
   /para
 
   paraThe following tables list existing packed RGB formats./para
@@ -176,8 +176,8 @@
/row
  /thead
  tbody valign=top
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
  dash-ent-24;
@@ -204,8 +204,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
  dash-ent-24;
@@ -232,8 +232,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
  dash-ent-24;
@@ -260,8 +260,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_LE/entry
  entry0x1004/entry
  entry/entry
  dash-ent-24;
@@ -288,8 +288,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-BE
- entryV4L2_MBUS_FMT_BGR565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-BE
+ entryMEDIA_BUS_FMT_BGR565_2X8_BE/entry
  entry0x1005/entry
  entry/entry
  dash-ent-24;
@@ -316,8 +316,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-LE
- entryV4L2_MBUS_FMT_BGR565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-LE
+ entryMEDIA_BUS_FMT_BGR565_2X8_LE/entry
  entry0x1006/entry
  entry/entry
  dash-ent-24;
@@ -344,8 +344,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-BE
- entryV4L2_MBUS_FMT_RGB565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-BE
+ entryMEDIA_BUS_FMT_RGB565_2X8_BE/entry
  entry0x1007/entry
  entry/entry
  dash-ent-24;
@@ -372,8 +372,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-LE
- entryV4L2_MBUS_FMT_RGB565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-LE
+ entryMEDIA_BUS_FMT_RGB565_2X8_LE/entry
  entry0x1008/entry
  entry/entry
  dash-ent-24;
@@ -400,8 +400,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB666-1X18
- entryV4L2_MBUS_FMT_RGB666_1X18/entry
+   row id=MEDIA-BUS-FMT-RGB666-1X18
+ entryMEDIA_BUS_FMT_RGB666_1X18/entry
  entry0x1009/entry

[PATCH v6 06/10] [media] platform: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all platform drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   7 +-
 arch/arm/mach-davinci/dm365.c  |   7 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/media/platform/blackfin/bfin_capture.c |  14 +--
 drivers/media/platform/davinci/vpbe.c  |   2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |   4 +-
 drivers/media/platform/exynos-gsc/gsc-core.c   |   8 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |   2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-core.h  |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  16 +--
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |  26 ++---
 drivers/media/platform/exynos4-is/fimc-lite.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-reg.c   |  14 +--
 drivers/media/platform/exynos4-is/mipi-csis.c  |  14 +--
 drivers/media/platform/marvell-ccic/mcam-core.c|  21 ++--
 drivers/media/platform/marvell-ccic/mcam-core.h|   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  | 112 ++---
 drivers/media/platform/omap3isp/ispccp2.c  |  18 ++--
 drivers/media/platform/omap3isp/ispcsi2.c  |  42 
 drivers/media/platform/omap3isp/isppreview.c   |  60 ++-
 drivers/media/platform/omap3isp/ispresizer.c   |  19 ++--
 drivers/media/platform/omap3isp/ispvideo.c |  95 +
 drivers/media/platform/omap3isp/ispvideo.h |  10 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  10 +-
 drivers/media/platform/s3c-camif/camif-regs.c  |   8 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c   |   2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c|   2 +-
 drivers/media/platform/sh_vou.c|   8 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |  22 ++--
 drivers/media/platform/soc_camera/mx2_camera.c |  26 +++--
 drivers/media/platform/soc_camera/mx3_camera.c |   6 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |  36 +++
 drivers/media/platform/soc_camera/pxa_camera.c |  16 +--
 drivers/media/platform/soc_camera/rcar_vin.c   |  14 +--
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  20 ++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  38 +++
 drivers/media/platform/soc_camera/soc_camera.c |   2 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |  78 +++---
 drivers/media/platform/via-camera.c|   8 +-
 drivers/media/platform/vsp1/vsp1_bru.c |  14 +--
 drivers/media/platform/vsp1/vsp1_hsit.c|  12 +--
 drivers/media/platform/vsp1/vsp1_lif.c |  10 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  14 +--
 drivers/media/platform/vsp1/vsp1_rwpf.c|  10 +-
 drivers/media/platform/vsp1/vsp1_sru.c |  12 +--
 drivers/media/platform/vsp1/vsp1_uds.c |  10 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  42 
 include/media/davinci/vpbe.h   |   2 +-
 include/media/davinci/vpbe_venc.h  |   5 +-
 include/media/exynos-fimc.h|   2 +-
 include/media/soc_camera.h |   2 +-
 include/media/soc_mediabus.h   |   6 +-
 59 files changed, 483 insertions(+), 495 deletions(-)

diff --git a/Documentation/video4linux/soc-camera.txt 
b/Documentation/video4linux/soc-camera.txt
index daa9e2a..84f41cf 100644
--- a/Documentation/video4linux/soc-camera.txt
+++ b/Documentation/video4linux/soc-camera.txt
@@ -151,7 +151,7 @@ they are transferred over a media bus. Soc-camera provides 
support to
 conveniently manage these formats. A table of standard transformations is
 maintained by soc-camera core, which describes, what FOURCC pixel format will
 be obtained, if a media-bus pixel format is stored in memory according to
-certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
+certain rules. E.g. if MEDIA_BUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
 sample and stored in memory in the little-endian order with no gaps between
 bytes, data in memory

[PATCH v6 08/10] staging: media: Make use of MEDIA_BUS_FMT_ definitions

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all media drivers residing in staging.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  18 ++--
 .../staging/media/davinci_vpfe/dm365_ipipe_hw.c|  26 +++---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 100 ++---
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  90 +--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  98 ++--
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  18 ++--
 drivers/staging/media/omap4iss/iss_csi2.c  |  62 ++---
 drivers/staging/media/omap4iss/iss_ipipe.c |  16 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  28 +++---
 drivers/staging/media/omap4iss/iss_resizer.c   |  26 +++---
 drivers/staging/media/omap4iss/iss_video.c |  78 
 drivers/staging/media/omap4iss/iss_video.h |  10 +--
 12 files changed, 285 insertions(+), 285 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index bdc7f00..704fa20 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -37,15 +37,15 @@
 
 /* ipipe input format's */
 static const unsigned int ipipe_input_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_SGRBG12_1X12,
-   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
-   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
+   MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
 };
 
 /* ipipe output format's */
 static const unsigned int ipipe_output_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
 };
 
 static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
@@ -1457,7 +1457,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use SBGGR10 as default */
if (i = ARRAY_SIZE(ipipe_input_fmts))
-   fmt-code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   fmt-code = MEDIA_BUS_FMT_SGRBG12_1X12;
} else if (pad == IPIPE_PAD_SOURCE) {
for (i = 0; i  ARRAY_SIZE(ipipe_output_fmts); i++)
if (fmt-code == ipipe_output_fmts[i])
@@ -1465,7 +1465,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use UYVY as default */
if (i = ARRAY_SIZE(ipipe_output_fmts))
-   fmt-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   fmt-code = MEDIA_BUS_FMT_UYVY8_2X8;
}
 
fmt-width = clamp_t(u32, fmt-width, MIN_OUT_HEIGHT, max_out_width);
@@ -1642,7 +1642,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SINK;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
@@ -1650,7 +1650,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SOURCE;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
+   format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index b2daf5e..6461de1 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -196,12 +196,12 @@ ipipe_setup_resizer(void *__iomem rsz_base, struct 
resizer_params *params)
rsz_set_rsz_regs(rsz_base, RSZ_B, params);
 }
 
-static u32 ipipe_get_color_pat(enum v4l2_mbus_pixelcode pix)
+static u32 ipipe_get_color_pat(u32 pix)
 {
switch (pix) {
-   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
return

[PATCH v6 00/10] [media] Make mediabus format subsystem neutral

2014-11-10 Thread Boris Brezillon
Hello,

This patch series prepares the use of media bus formats outside of
the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
driver where I have to configure my DPI/RGB bus according to the
connected display).

The series first defines MEDIA_BUS_FMT_ macros, and then replace all
references to the v4l2_mbus_pixelcode enum and its values within the
kernel.

Best Regards,

Boris

Changes since v5:
- fix V4L2_MBUS_FROM_MEDIA_BUS_FMT macro definition

Changes since v4:
- put deprecated enum v4l2_mbus_pixelcode at the end of v4l2-mediabus.h
  header

Changes since v3:
- add a comment specifying that the v4l2_mbus_pixelcode enum definition
  is frozen

Changes since v2:
- drop media_bus_format enum and replace its values with pre-processor
  macros

Changes since v1:
- drop patches deprecating v4l2_mbus_pixelcode for user-space users
- put V4L2 legacy format definitions into media-bus-format.h

Boris Brezillon (10):
  [media] Move mediabus format definition to a more standard place
  [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values
  [media] Make use of the new media_bus_format definitions
  [media] i2c: Make use of media_bus_format enum
  [media] pci: Make use of MEDIA_BUS_FMT definitions
  [media] platform: Make use of media_bus_format enum
  [media] usb: Make use of media_bus_format enum
  staging: media: Make use of MEDIA_BUS_FMT_ definitions
  gpu: ipu-v3: Make use of media_bus_format enum
  [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the
kernel

 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   7 +-
 arch/arm/mach-davinci/dm365.c  |   7 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |  66 ++---
 drivers/media/i2c/adv7170.c|  16 +-
 drivers/media/i2c/adv7175.c|  16 +-
 drivers/media/i2c/adv7180.c|   6 +-
 drivers/media/i2c/adv7183.c|   6 +-
 drivers/media/i2c/adv7604.c|  72 ++---
 drivers/media/i2c/adv7842.c|   6 +-
 drivers/media/i2c/ak881x.c |   8 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   6 +-
 drivers/media/i2c/ml86v7667.c  |   6 +-
 drivers/media/i2c/mt9m032.c|   6 +-
 drivers/media/i2c/mt9p031.c|   8 +-
 drivers/media/i2c/mt9t001.c|   8 +-
 drivers/media/i2c/mt9v011.c|   6 +-
 drivers/media/i2c/mt9v032.c|  12 +-
 drivers/media/i2c/noon010pc30.c|  12 +-
 drivers/media/i2c/ov7670.c |  16 +-
 drivers/media/i2c/ov9650.c |  10 +-
 drivers/media/i2c/s5c73m3/s5c73m3.h|   6 +-
 drivers/media/i2c/s5k4ecgx.c   |   4 +-
 drivers/media/i2c/s5k5baf.c|  14 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   8 +-
 drivers/media/i2c/saa6752hs.c  |   6 +-
 drivers/media/i2c/saa7115.c|   2 +-
 drivers/media/i2c/saa717x.c|   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  32 +--
 drivers/media/i2c/soc_camera/imx074.c  |   8 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  14 +-
 drivers/media/i2c/soc_camera/mt9m111.c |  70 ++---
 drivers/media/i2c/soc_camera/mt9t031.c |  10 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  22 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  26 +-
 drivers/media/i2c/soc_camera/ov2640.c  |  54 ++--
 drivers/media/i2c/soc_camera/ov5642.c  |   8 +-
 drivers/media/i2c/soc_camera/ov6650.c  |  58 ++--
 drivers/media/i2c/soc_camera/ov772x.c  |  20 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  40 +--
 drivers/media/i2c/soc_camera/ov9740.c  |  12 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  54 ++--
 drivers/media/i2c/soc_camera/tw9910.c  |  10 +-
 drivers/media/i2c/sr030pc30.c  |  14 +-
 drivers/media/i2c/tvp514x.c|  12 +-
 drivers/media/i2c/tvp5150.c|   6 +-
 drivers/media/i2c/tvp7002.c|  10 +-
 drivers/media/i2c/vs6624.c |  18 +-
 drivers/media/pci/cx18/cx18-av-core.c  |   2 +-
 drivers/media

[PATCH v6 01/10] [media] Move mediabus format definition to a more standard place

2014-11-10 Thread Boris Brezillon
Define MEDIA_BUS_FMT macros (re-using the values defined in the
v4l2_mbus_pixelcode enum) into a separate header file so that they can be
used from the DRM/KMS subsystem without any reference to the V4L2
subsystem.

Then set V4L2_MBUS_FMT definitions to the MEDIA_BUS_FMT values using the
V4L2_MBUS_FROM_MEDIA_BUS_FMT macro.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/media-bus-format.h | 125 +++
 include/uapi/linux/v4l2-mediabus.h| 184 +++---
 3 files changed, 206 insertions(+), 104 deletions(-)
 create mode 100644 include/uapi/linux/media-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e..ed39ac8 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -241,6 +241,7 @@ header-y += map_to_7segment.h
 header-y += matroxfb.h
 header-y += mdio.h
 header-y += media.h
+header-y += media-bus-format.h
 header-y += mei.h
 header-y += memfd.h
 header-y += mempolicy.h
diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
new file mode 100644
index 000..23b4090
--- /dev/null
+++ b/include/uapi/linux/media-bus-format.h
@@ -0,0 +1,125 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MEDIA_BUS_FORMAT_H
+#define __LINUX_MEDIA_BUS_FORMAT_H
+
+/*
+ * These bus formats uniquely identify data formats on the data bus. Format 0
+ * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where
+ * the data format is fixed. Additionally, 2X8 means that one pixel is
+ * transferred in two 8-bit samples, BE or LE specify in which order those
+ * samples are transferred over the bus: LE means that the least significant
+ * bits are transferred first, BE means that the most significant bits are
+ * transferred first, and PADHI and PADLO define which bits - low or high,
+ * in the incomplete high byte, are filled with padding bits.
+ *
+ * The bus formats are grouped by type, bus_width, bits per component, samples
+ * per pixel and order of subsamples. Numerical values are sorted using generic
+ * numerical sort order (8 thus comes before 10).
+ *
+ * As their value can't change when a new bus format is inserted in the
+ * enumeration, the bus formats are explicitly given a numerical value. The 
next
+ * free values for each category are listed below, update them when inserting
+ * new pixel codes.
+ */
+
+#define MEDIA_BUS_FMT_FIXED0x0001
+
+/* RGB - next is   0x100e */
+#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE  0x1001
+#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE  0x1002
+#define MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE  0x1003
+#define MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE  0x1004
+#define MEDIA_BUS_FMT_BGR565_2X8_BE0x1005
+#define MEDIA_BUS_FMT_BGR565_2X8_LE0x1006
+#define MEDIA_BUS_FMT_RGB565_2X8_BE0x1007
+#define MEDIA_BUS_FMT_RGB565_2X8_LE0x1008
+#define MEDIA_BUS_FMT_RGB666_1X18  0x1009
+#define MEDIA_BUS_FMT_RGB888_1X24  0x100a
+#define MEDIA_BUS_FMT_RGB888_2X12_BE   0x100b
+#define MEDIA_BUS_FMT_RGB888_2X12_LE   0x100c
+#define MEDIA_BUS_FMT_ARGB_1X320x100d
+
+/* YUV (including grey) - next is  0x2024 */
+#define MEDIA_BUS_FMT_Y8_1X8   0x2001
+#define MEDIA_BUS_FMT_UV8_1X8  0x2015
+#define MEDIA_BUS_FMT_UYVY8_1_5X8  0x2002
+#define MEDIA_BUS_FMT_VYUY8_1_5X8  0x2003
+#define MEDIA_BUS_FMT_YUYV8_1_5X8  0x2004
+#define MEDIA_BUS_FMT_YVYU8_1_5X8  0x2005
+#define MEDIA_BUS_FMT_UYVY8_2X80x2006
+#define MEDIA_BUS_FMT_VYUY8_2X80x2007
+#define MEDIA_BUS_FMT_YUYV8_2X80x2008
+#define MEDIA_BUS_FMT_YVYU8_2X80x2009
+#define MEDIA_BUS_FMT_Y10_1X10 0x200a
+#define MEDIA_BUS_FMT_UYVY10_2X10  0x2018
+#define MEDIA_BUS_FMT_VYUY10_2X10  0x2019
+#define MEDIA_BUS_FMT_YUYV10_2X10  0x200b
+#define MEDIA_BUS_FMT_YVYU10_2X10  0x200c
+#define MEDIA_BUS_FMT_Y12_1X12 0x2013
+#define MEDIA_BUS_FMT_UYVY8_1X16   0x200f
+#define MEDIA_BUS_FMT_VYUY8_1X16   0x2010
+#define MEDIA_BUS_FMT_YUYV8_1X16   0x2011
+#define MEDIA_BUS_FMT_YVYU8_1X16   0x2012
+#define MEDIA_BUS_FMT_YDYUYDYV8_1X16   0x2014
+#define MEDIA_BUS_FMT_UYVY10_1X20

[PATCH v6 03/10] [media] Make use of the new media_bus_format definitions

2014-11-10 Thread Boris Brezillon
Replace references to the v4l2_mbus_pixelcode enum with the new
media_bus_format enum in all common headers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 include/media/v4l2-mediabus.h| 2 +-
 include/media/v4l2-subdev.h  | 2 +-
 include/uapi/linux/v4l2-subdev.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 395c4a9..59d7397 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -98,7 +98,7 @@ static inline void v4l2_fill_pix_format(struct 
v4l2_pix_format *pix_fmt,
 
 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
   const struct v4l2_pix_format *pix_fmt,
-  enum v4l2_mbus_pixelcode code)
+  u32 code)
 {
mbus_fmt-width = pix_fmt-width;
mbus_fmt-height = pix_fmt-height;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d746572..5860292 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -341,7 +341,7 @@ struct v4l2_subdev_video_ops {
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
-enum v4l2_mbus_pixelcode *code);
+u32 *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a619cdd..e0a7e3d 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -68,7 +68,7 @@ struct v4l2_subdev_crop {
  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  */
 struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -81,7 +81,7 @@ struct v4l2_subdev_mbus_code_enum {
  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  */
 struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -109,7 +109,7 @@ struct v4l2_subdev_frame_interval {
  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
  * @pad: pad number, as reported by the media API
  * @index: frame interval index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 07/10] [media] usb: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all usb drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++--
 drivers/media/usb/em28xx/em28xx-camera.c  | 2 +-
 drivers/media/usb/go7007/go7007-v4l2.c| 2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 459bb0e..95653ba 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1878,7 +1878,7 @@ static int cx231xx_s_video_encoding(struct 
cx2341x_handler *cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev-sd_cx25840, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 3b3ada6..989d527 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -967,7 +967,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-height = f-fmt.pix.height;
dev-format = fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
 
@@ -1012,7 +1012,7 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id norm)
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
memset(mbus_fmt, 0, sizeof(mbus_fmt));
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = dev-width;
mbus_fmt.height = dev-height;
call_all(dev, video, s_mbus_fmt, mbus_fmt);
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index 6d2ea9a..38cf6c8 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -430,7 +430,7 @@ int em28xx_init_camera(struct em28xx *dev)
break;
}
 
-   fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
+   fmt.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640;
fmt.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, fmt);
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c 
b/drivers/media/usb/go7007/go7007-v4l2.c
index ec799b4..d6bf982 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct 
v4l2_format *fmt, int try)
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt;
 
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt-fmt.pix.width : width;
mbus_fmt.height = height;
go-encoder_h_halve = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 9623b62..2fd9b5e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
memset(fmt, 0, sizeof(fmt));
fmt.width = hdw-res_hor_val;
fmt.height = hdw-res_ver_val;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, subdev v4l2 set_size(%dx%d),
   fmt.width, fmt.height);
v4l2_device_call_all(hdw-v4l2_dev, 0, video, s_mbus_fmt, 
fmt);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 RESEND 07/10] [media] usb: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all usb drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++--
 drivers/media/usb/em28xx/em28xx-camera.c  | 2 +-
 drivers/media/usb/go7007/go7007-v4l2.c| 2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 459bb0e..95653ba 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1878,7 +1878,7 @@ static int cx231xx_s_video_encoding(struct 
cx2341x_handler *cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev-sd_cx25840, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 3b3ada6..989d527 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -967,7 +967,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-height = f-fmt.pix.height;
dev-format = fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
 
@@ -1012,7 +1012,7 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id norm)
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
memset(mbus_fmt, 0, sizeof(mbus_fmt));
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = dev-width;
mbus_fmt.height = dev-height;
call_all(dev, video, s_mbus_fmt, mbus_fmt);
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index 6d2ea9a..38cf6c8 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -430,7 +430,7 @@ int em28xx_init_camera(struct em28xx *dev)
break;
}
 
-   fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
+   fmt.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640;
fmt.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, fmt);
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c 
b/drivers/media/usb/go7007/go7007-v4l2.c
index ec799b4..d6bf982 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct 
v4l2_format *fmt, int try)
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt;
 
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt-fmt.pix.width : width;
mbus_fmt.height = height;
go-encoder_h_halve = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 9623b62..2fd9b5e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
memset(fmt, 0, sizeof(fmt));
fmt.width = hdw-res_hor_val;
fmt.height = hdw-res_ver_val;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, subdev v4l2 set_size(%dx%d),
   fmt.width, fmt.height);
v4l2_device_call_all(hdw-v4l2_dev, 0, video, s_mbus_fmt, 
fmt);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 RESEND 03/10] [media] Make use of the new media_bus_format definitions

2014-11-10 Thread Boris Brezillon
Replace references to the v4l2_mbus_pixelcode enum with the new
media_bus_format enum in all common headers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 include/media/v4l2-mediabus.h| 2 +-
 include/media/v4l2-subdev.h  | 2 +-
 include/uapi/linux/v4l2-subdev.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 395c4a9..59d7397 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -98,7 +98,7 @@ static inline void v4l2_fill_pix_format(struct 
v4l2_pix_format *pix_fmt,
 
 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
   const struct v4l2_pix_format *pix_fmt,
-  enum v4l2_mbus_pixelcode code)
+  u32 code)
 {
mbus_fmt-width = pix_fmt-width;
mbus_fmt-height = pix_fmt-height;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d746572..5860292 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -341,7 +341,7 @@ struct v4l2_subdev_video_ops {
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
-enum v4l2_mbus_pixelcode *code);
+u32 *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a619cdd..e0a7e3d 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -68,7 +68,7 @@ struct v4l2_subdev_crop {
  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  */
 struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -81,7 +81,7 @@ struct v4l2_subdev_mbus_code_enum {
  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  */
 struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -109,7 +109,7 @@ struct v4l2_subdev_frame_interval {
  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
  * @pad: pad number, as reported by the media API
  * @index: frame interval index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (MEDIA_BUS_FMT_ definitions)
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6 00/10] [media] Make mediabus format subsystem neutral

2014-11-10 Thread Boris Brezillon
On Mon, 10 Nov 2014 18:21:44 +0100
Boris Brezillon boris.brezil...@free-electrons.com wrote:

 Hello,
 
 This patch series prepares the use of media bus formats outside of
 the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
 driver where I have to configure my DPI/RGB bus according to the
 connected display).
 
 The series first defines MEDIA_BUS_FMT_ macros, and then replace all
 references to the v4l2_mbus_pixelcode enum and its values within the
 kernel.
 
 Best Regards,
 
 Boris
 
 Changes since v5:
 - fix V4L2_MBUS_FROM_MEDIA_BUS_FMT macro definition

Sorry for the noise, I sent the wrong patch set :-(.

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 RESEND 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-10 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/uapi/linux/v4l2-mediabus.h | 45 --
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 2618084..b1934a3 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,6 +15,33 @@
 #include linux/types.h
 #include linux/videodev2.h
 
+/**
+ * struct v4l2_mbus_framefmt - frame format on the media bus
+ * @width: frame width
+ * @height:frame height
+ * @code:  data format code (from enum v4l2_mbus_pixelcode)
+ * @field: used interlacing type (from enum v4l2_field)
+ * @colorspace:colorspace of the data (from enum v4l2_colorspace)
+ */
+struct v4l2_mbus_framefmt {
+   __u32   width;
+   __u32   height;
+   __u32   code;
+   __u32   field;
+   __u32   colorspace;
+   __u32   reserved[7];
+};
+
+#ifndef __KERNEL__
+/*
+ * enum v4l2_mbus_pixelcode and its definitions are now deprecated, and
+ * MEDIA_BUS_FMT_ definitions (defined in media-bus-format.h) should be
+ * used instead.
+ *
+ * New defines should only be added to media-bus-format.h. The
+ * v4l2_mbus_pixelcode enum is frozen.
+ */
+
 #define V4L2_MBUS_FROM_MEDIA_BUS_FMT(name) \
V4L2_MBUS_FMT_ ## name = MEDIA_BUS_FMT_ ## name
 
@@ -102,22 +129,6 @@ enum v4l2_mbus_pixelcode {
 
V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV_1X32),
 };
-
-/**
- * struct v4l2_mbus_framefmt - frame format on the media bus
- * @width: frame width
- * @height:frame height
- * @code:  data format code (from enum v4l2_mbus_pixelcode)
- * @field: used interlacing type (from enum v4l2_field)
- * @colorspace:colorspace of the data (from enum v4l2_colorspace)
- */
-struct v4l2_mbus_framefmt {
-   __u32   width;
-   __u32   height;
-   __u32   code;
-   __u32   field;
-   __u32   colorspace;
-   __u32   reserved[7];
-};
+#endif /* __KERNEL__ */
 
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 RESEND 05/10] [media] pci: Make use of MEDIA_BUS_FMT definitions

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in pci drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/pci/cx18/cx18-av-core.c   | 2 +-
 drivers/media/pci/cx18/cx18-controls.c  | 2 +-
 drivers/media/pci/cx18/cx18-ioctl.c | 2 +-
 drivers/media/pci/cx23885/cx23885-video.c   | 2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c | 2 +-
 drivers/media/pci/saa7134/saa7134-empress.c | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-av-core.c 
b/drivers/media/pci/cx18/cx18-av-core.c
index 2d3afe0..4c6ce21 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, 
struct v4l2_mbus_framefmt
int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
int is_50Hz = !(state-std  V4L2_STD_525_60);
 
-   if (fmt-code != V4L2_MBUS_FMT_FIXED)
+   if (fmt-code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
 
fmt-field = V4L2_FIELD_INTERLACED;
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 282a3d2..4aeb7c6 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 6f2b590..71963db 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
 
mbus_fmt.width = cx-cxhdl.width = w;
mbus_fmt.height = cx-cxhdl.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, mbus_fmt);
return cx18_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f9..091f5db 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -608,7 +608,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-field  = f-fmt.pix.field;
dprintk(2, %s() width=%d height=%d field=%d\n, __func__,
dev-width, dev-height, dev-field);
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
/* s_mbus_fmt overwrites f-fmt.pix.field, restore it */
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 2b0ab26..ccf548c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3e0cb77..4d8ee18 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, 
struct v4l2_format *f
fmt-fmt.pix.width /= 2;
mbus_fmt.width = fmt-fmt.pix.width;
mbus_fmt.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, mbus_fmt);
return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c 
b/drivers/media/pci/saa7134/saa7134-empress.c
index e4ea85f..8b3bb78 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -140,7 +140,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void 
*priv,
struct saa7134_dev *dev = video_drvdata

[PATCH v6 RESEND 02/10] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed them with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Update the v4l documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 1 file changed, 154 insertions(+), 154 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..18730b9 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -86,7 +86,7 @@
   green and 5-bit blue values padded on the high bit, transferred as 2 
8-bit
   samples per pixel with the most significant bits (padding, red and half 
of
   the green value) transferred first will be named
-  constantV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/constant.
+  constantMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/constant.
   /para
 
   paraThe following tables list existing packed RGB formats./para
@@ -176,8 +176,8 @@
/row
  /thead
  tbody valign=top
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
  dash-ent-24;
@@ -204,8 +204,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
  dash-ent-24;
@@ -232,8 +232,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
  dash-ent-24;
@@ -260,8 +260,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_LE/entry
  entry0x1004/entry
  entry/entry
  dash-ent-24;
@@ -288,8 +288,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-BE
- entryV4L2_MBUS_FMT_BGR565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-BE
+ entryMEDIA_BUS_FMT_BGR565_2X8_BE/entry
  entry0x1005/entry
  entry/entry
  dash-ent-24;
@@ -316,8 +316,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-LE
- entryV4L2_MBUS_FMT_BGR565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-LE
+ entryMEDIA_BUS_FMT_BGR565_2X8_LE/entry
  entry0x1006/entry
  entry/entry
  dash-ent-24;
@@ -344,8 +344,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-BE
- entryV4L2_MBUS_FMT_RGB565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-BE
+ entryMEDIA_BUS_FMT_RGB565_2X8_BE/entry
  entry0x1007/entry
  entry/entry
  dash-ent-24;
@@ -372,8 +372,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-LE
- entryV4L2_MBUS_FMT_RGB565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-LE
+ entryMEDIA_BUS_FMT_RGB565_2X8_LE/entry
  entry0x1008/entry
  entry/entry
  dash-ent-24;
@@ -400,8 +400,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB666-1X18
- entryV4L2_MBUS_FMT_RGB666_1X18/entry
+   row id=MEDIA-BUS-FMT-RGB666-1X18
+ entryMEDIA_BUS_FMT_RGB666_1X18/entry
  entry0x1009/entry

[PATCH v6 RESEND 00/10] [media] Make mediabus format subsystem neutral

2014-11-10 Thread Boris Brezillon
Hello,

This patch series prepares the use of media bus formats outside of
the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
driver where I have to configure my DPI/RGB bus according to the
connected display).

The series first defines MEDIA_BUS_FMT_ macros, and then replace all
references to the v4l2_mbus_pixelcode enum and its values within the
kernel.

Best Regards,

Boris

Changes since v5:
- fix V4L2_MBUS_FROM_MEDIA_BUS_FMT macro definition

Changes since v4:
- put deprecated enum v4l2_mbus_pixelcode at the end of v4l2-mediabus.h
  header

Changes since v3:
- add a comment specifying that the v4l2_mbus_pixelcode enum definition
  is frozen

Changes since v2:
- drop media_bus_format enum and replace its values with pre-processor
  macros

Changes since v1:
- drop patches deprecating v4l2_mbus_pixelcode for user-space users
- put V4L2 legacy format definitions into media-bus-format.h


Boris Brezillon (10):
  [media] Move mediabus format definition to a more standard place
  [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values
  [media] Make use of the new media_bus_format definitions
  [media] i2c: Make use of media_bus_format enum
  [media] pci: Make use of MEDIA_BUS_FMT definitions
  [media] platform: Make use of media_bus_format enum
  [media] usb: Make use of media_bus_format enum
  staging: media: Make use of MEDIA_BUS_FMT_ definitions
  gpu: ipu-v3: Make use of media_bus_format enum
  [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the
kernel

 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   7 +-
 arch/arm/mach-davinci/dm365.c  |   7 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |  66 ++---
 drivers/media/i2c/adv7170.c|  16 +-
 drivers/media/i2c/adv7175.c|  16 +-
 drivers/media/i2c/adv7180.c|   6 +-
 drivers/media/i2c/adv7183.c|   6 +-
 drivers/media/i2c/adv7604.c|  72 ++---
 drivers/media/i2c/adv7842.c|   6 +-
 drivers/media/i2c/ak881x.c |   8 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   6 +-
 drivers/media/i2c/ml86v7667.c  |   6 +-
 drivers/media/i2c/mt9m032.c|   6 +-
 drivers/media/i2c/mt9p031.c|   8 +-
 drivers/media/i2c/mt9t001.c|   8 +-
 drivers/media/i2c/mt9v011.c|   6 +-
 drivers/media/i2c/mt9v032.c|  12 +-
 drivers/media/i2c/noon010pc30.c|  12 +-
 drivers/media/i2c/ov7670.c |  16 +-
 drivers/media/i2c/ov9650.c |  10 +-
 drivers/media/i2c/s5c73m3/s5c73m3.h|   6 +-
 drivers/media/i2c/s5k4ecgx.c   |   4 +-
 drivers/media/i2c/s5k5baf.c|  14 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   8 +-
 drivers/media/i2c/saa6752hs.c  |   6 +-
 drivers/media/i2c/saa7115.c|   2 +-
 drivers/media/i2c/saa717x.c|   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  32 +--
 drivers/media/i2c/soc_camera/imx074.c  |   8 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  14 +-
 drivers/media/i2c/soc_camera/mt9m111.c |  70 ++---
 drivers/media/i2c/soc_camera/mt9t031.c |  10 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  22 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  26 +-
 drivers/media/i2c/soc_camera/ov2640.c  |  54 ++--
 drivers/media/i2c/soc_camera/ov5642.c  |   8 +-
 drivers/media/i2c/soc_camera/ov6650.c  |  58 ++--
 drivers/media/i2c/soc_camera/ov772x.c  |  20 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  40 +--
 drivers/media/i2c/soc_camera/ov9740.c  |  12 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  54 ++--
 drivers/media/i2c/soc_camera/tw9910.c  |  10 +-
 drivers/media/i2c/sr030pc30.c  |  14 +-
 drivers/media/i2c/tvp514x.c|  12 +-
 drivers/media/i2c/tvp5150.c|   6 +-
 drivers/media/i2c/tvp7002.c|  10 +-
 drivers/media/i2c/vs6624.c |  18 +-
 drivers/media/pci/cx18/cx18-av-core.c  |   2 +-
 drivers/media

[PATCH v6 RESEND 04/10] [media] i2c: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definitions to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in i2c drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/adv7170.c   | 16 +++
 drivers/media/i2c/adv7175.c   | 16 +++
 drivers/media/i2c/adv7180.c   |  6 +--
 drivers/media/i2c/adv7183.c   |  6 +--
 drivers/media/i2c/adv7604.c   | 72 +++
 drivers/media/i2c/adv7842.c   |  6 +--
 drivers/media/i2c/ak881x.c|  8 ++--
 drivers/media/i2c/cx25840/cx25840-core.c  |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c|  6 +--
 drivers/media/i2c/ml86v7667.c |  6 +--
 drivers/media/i2c/mt9m032.c   |  6 +--
 drivers/media/i2c/mt9p031.c   |  8 ++--
 drivers/media/i2c/mt9t001.c   |  8 ++--
 drivers/media/i2c/mt9v011.c   |  6 +--
 drivers/media/i2c/mt9v032.c   | 12 +++---
 drivers/media/i2c/noon010pc30.c   | 12 +++---
 drivers/media/i2c/ov7670.c| 16 +++
 drivers/media/i2c/ov9650.c| 10 ++---
 drivers/media/i2c/s5c73m3/s5c73m3.h   |  6 +--
 drivers/media/i2c/s5k4ecgx.c  |  4 +-
 drivers/media/i2c/s5k5baf.c   | 14 +++---
 drivers/media/i2c/s5k6a3.c|  2 +-
 drivers/media/i2c/s5k6aa.c|  8 ++--
 drivers/media/i2c/saa6752hs.c |  6 +--
 drivers/media/i2c/saa7115.c   |  2 +-
 drivers/media/i2c/saa717x.c   |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 32 +++---
 drivers/media/i2c/soc_camera/imx074.c |  8 ++--
 drivers/media/i2c/soc_camera/mt9m001.c| 14 +++---
 drivers/media/i2c/soc_camera/mt9m111.c| 70 +++---
 drivers/media/i2c/soc_camera/mt9t031.c| 10 ++---
 drivers/media/i2c/soc_camera/mt9t112.c| 22 +-
 drivers/media/i2c/soc_camera/mt9v022.c| 26 +--
 drivers/media/i2c/soc_camera/ov2640.c | 54 +++
 drivers/media/i2c/soc_camera/ov5642.c |  8 ++--
 drivers/media/i2c/soc_camera/ov6650.c | 58 -
 drivers/media/i2c/soc_camera/ov772x.c | 20 -
 drivers/media/i2c/soc_camera/ov9640.c | 40 -
 drivers/media/i2c/soc_camera/ov9740.c | 12 +++---
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 54 +++
 drivers/media/i2c/soc_camera/tw9910.c | 10 ++---
 drivers/media/i2c/sr030pc30.c | 14 +++---
 drivers/media/i2c/tvp514x.c   | 12 +++---
 drivers/media/i2c/tvp5150.c   |  6 +--
 drivers/media/i2c/tvp7002.c   | 10 ++---
 drivers/media/i2c/vs6624.c| 18 
 46 files changed, 382 insertions(+), 382 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index 04bb297..40a1a95 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { pass_through, play_back };
 
-static enum v4l2_mbus_pixelcode adv7170_codes[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_UYVY8_1X16,
+static u32 adv7170_codes[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_1X16,
 };
 
 /* --- */
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
 }
 
 static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-   enum v4l2_mbus_pixelcode *code)
+   u32 *code)
 {
if (index = ARRAY_SIZE(adv7170_codes))
return -EINVAL;
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd,
u8 val = adv7170_read(sd, 0x7);
 
if ((val  0x40) == (1  6))
-   mf-code = V4L2_MBUS_FMT_UYVY8_1X16;
+   mf-code = MEDIA_BUS_FMT_UYVY8_1X16;
else
-   mf-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   mf-code = MEDIA_BUS_FMT_UYVY8_2X8;
 
mf-colorspace  = V4L2_COLORSPACE_SMPTE170M;
mf-width   = 0;
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
int ret;
 
switch (mf-code) {
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
val = ~0x40;
break;
 
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
val |= 0x40;
break;
 
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index b88f3b3..d220af5 100644
--- a/drivers/media

[PATCH v6 RESEND 09/10] gpu: ipu-v3: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in the ipu-v3 driver.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 66 ++--
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index d6f56471..752cdd2 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -227,83 +227,83 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, 
u32 pixel_clk,
 static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 {
switch (mbus_code) {
-   case V4L2_MBUS_FMT_BGR565_2X8_BE:
-   case V4L2_MBUS_FMT_BGR565_2X8_LE:
-   case V4L2_MBUS_FMT_RGB565_2X8_BE:
-   case V4L2_MBUS_FMT_RGB565_2X8_LE:
+   case MEDIA_BUS_FMT_BGR565_2X8_BE:
+   case MEDIA_BUS_FMT_BGR565_2X8_LE:
+   case MEDIA_BUS_FMT_RGB565_2X8_BE:
+   case MEDIA_BUS_FMT_RGB565_2X8_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
cfg-mipi_dt = MIPI_DT_RGB565;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB444;
cfg-mipi_dt = MIPI_DT_RGB444;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB555;
cfg-mipi_dt = MIPI_DT_RGB555;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_YUYV8_2X8:
+   case MEDIA_BUS_FMT_YUYV8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_YUYV8_1X16:
+   case MEDIA_BUS_FMT_YUYV8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_SBGGR8_1X8:
-   case V4L2_MBUS_FMT_SGBRG8_1X8:
-   case V4L2_MBUS_FMT_SGRBG8_1X8:
-   case V4L2_MBUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW8;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+   case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW10;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_1X10:
-   case V4L2_MBUS_FMT_SGBRG10_1X10:
-   case V4L2_MBUS_FMT_SGRBG10_1X10:
-   case V4L2_MBUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case

[PATCH v6 RESEND 06/10] [media] platform: Make use of media_bus_format enum

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all platform drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   7 +-
 arch/arm/mach-davinci/dm365.c  |   7 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/media/platform/blackfin/bfin_capture.c |  14 +--
 drivers/media/platform/davinci/vpbe.c  |   2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |   4 +-
 drivers/media/platform/exynos-gsc/gsc-core.c   |   8 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |   2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-core.h  |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  16 +--
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |  26 ++---
 drivers/media/platform/exynos4-is/fimc-lite.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-reg.c   |  14 +--
 drivers/media/platform/exynos4-is/mipi-csis.c  |  14 +--
 drivers/media/platform/marvell-ccic/mcam-core.c|  21 ++--
 drivers/media/platform/marvell-ccic/mcam-core.h|   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  | 112 ++---
 drivers/media/platform/omap3isp/ispccp2.c  |  18 ++--
 drivers/media/platform/omap3isp/ispcsi2.c  |  42 
 drivers/media/platform/omap3isp/isppreview.c   |  60 ++-
 drivers/media/platform/omap3isp/ispresizer.c   |  19 ++--
 drivers/media/platform/omap3isp/ispvideo.c |  95 +
 drivers/media/platform/omap3isp/ispvideo.h |  10 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  10 +-
 drivers/media/platform/s3c-camif/camif-regs.c  |   8 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c   |   2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c|   2 +-
 drivers/media/platform/sh_vou.c|   8 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |  22 ++--
 drivers/media/platform/soc_camera/mx2_camera.c |  26 +++--
 drivers/media/platform/soc_camera/mx3_camera.c |   6 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |  36 +++
 drivers/media/platform/soc_camera/pxa_camera.c |  16 +--
 drivers/media/platform/soc_camera/rcar_vin.c   |  14 +--
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  20 ++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  38 +++
 drivers/media/platform/soc_camera/soc_camera.c |   2 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |  78 +++---
 drivers/media/platform/via-camera.c|   8 +-
 drivers/media/platform/vsp1/vsp1_bru.c |  14 +--
 drivers/media/platform/vsp1/vsp1_hsit.c|  12 +--
 drivers/media/platform/vsp1/vsp1_lif.c |  10 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  14 +--
 drivers/media/platform/vsp1/vsp1_rwpf.c|  10 +-
 drivers/media/platform/vsp1/vsp1_sru.c |  12 +--
 drivers/media/platform/vsp1/vsp1_uds.c |  10 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  42 
 include/media/davinci/vpbe.h   |   2 +-
 include/media/davinci/vpbe_venc.h  |   5 +-
 include/media/exynos-fimc.h|   2 +-
 include/media/soc_camera.h |   2 +-
 include/media/soc_mediabus.h   |   6 +-
 59 files changed, 483 insertions(+), 495 deletions(-)

diff --git a/Documentation/video4linux/soc-camera.txt 
b/Documentation/video4linux/soc-camera.txt
index daa9e2a..84f41cf 100644
--- a/Documentation/video4linux/soc-camera.txt
+++ b/Documentation/video4linux/soc-camera.txt
@@ -151,7 +151,7 @@ they are transferred over a media bus. Soc-camera provides 
support to
 conveniently manage these formats. A table of standard transformations is
 maintained by soc-camera core, which describes, what FOURCC pixel format will
 be obtained, if a media-bus pixel format is stored in memory according to
-certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
+certain rules. E.g. if MEDIA_BUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
 sample and stored in memory in the little-endian order with no gaps between
 bytes, data in memory

[PATCH v6 RESEND 08/10] staging: media: Make use of MEDIA_BUS_FMT_ definitions

2014-11-10 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all media drivers residing in staging.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  18 ++--
 .../staging/media/davinci_vpfe/dm365_ipipe_hw.c|  26 +++---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 100 ++---
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  90 +--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  98 ++--
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  18 ++--
 drivers/staging/media/omap4iss/iss_csi2.c  |  62 ++---
 drivers/staging/media/omap4iss/iss_ipipe.c |  16 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  28 +++---
 drivers/staging/media/omap4iss/iss_resizer.c   |  26 +++---
 drivers/staging/media/omap4iss/iss_video.c |  78 
 drivers/staging/media/omap4iss/iss_video.h |  10 +--
 12 files changed, 285 insertions(+), 285 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index bdc7f00..704fa20 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -37,15 +37,15 @@
 
 /* ipipe input format's */
 static const unsigned int ipipe_input_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_SGRBG12_1X12,
-   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
-   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
+   MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
 };
 
 /* ipipe output format's */
 static const unsigned int ipipe_output_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
 };
 
 static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
@@ -1457,7 +1457,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use SBGGR10 as default */
if (i = ARRAY_SIZE(ipipe_input_fmts))
-   fmt-code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   fmt-code = MEDIA_BUS_FMT_SGRBG12_1X12;
} else if (pad == IPIPE_PAD_SOURCE) {
for (i = 0; i  ARRAY_SIZE(ipipe_output_fmts); i++)
if (fmt-code == ipipe_output_fmts[i])
@@ -1465,7 +1465,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use UYVY as default */
if (i = ARRAY_SIZE(ipipe_output_fmts))
-   fmt-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   fmt-code = MEDIA_BUS_FMT_UYVY8_2X8;
}
 
fmt-width = clamp_t(u32, fmt-width, MIN_OUT_HEIGHT, max_out_width);
@@ -1642,7 +1642,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SINK;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
@@ -1650,7 +1650,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SOURCE;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
+   format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index b2daf5e..6461de1 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -196,12 +196,12 @@ ipipe_setup_resizer(void *__iomem rsz_base, struct 
resizer_params *params)
rsz_set_rsz_regs(rsz_base, RSZ_B, params);
 }
 
-static u32 ipipe_get_color_pat(enum v4l2_mbus_pixelcode pix)
+static u32 ipipe_get_color_pat(u32 pix)
 {
switch (pix) {
-   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
return

[PATCH v6 RESEND 01/10] [media] Move mediabus format definition to a more standard place

2014-11-10 Thread Boris Brezillon
Define MEDIA_BUS_FMT macros (re-using the values defined in the
v4l2_mbus_pixelcode enum) into a separate header file so that they can be
used from the DRM/KMS subsystem without any reference to the V4L2
subsystem.

Then set V4L2_MBUS_FMT definitions to the MEDIA_BUS_FMT values using the
V4L2_MBUS_FROM_MEDIA_BUS_FMT macro.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/media-bus-format.h | 125 +++
 include/uapi/linux/v4l2-mediabus.h| 184 +++---
 3 files changed, 206 insertions(+), 104 deletions(-)
 create mode 100644 include/uapi/linux/media-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e..ed39ac8 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -241,6 +241,7 @@ header-y += map_to_7segment.h
 header-y += matroxfb.h
 header-y += mdio.h
 header-y += media.h
+header-y += media-bus-format.h
 header-y += mei.h
 header-y += memfd.h
 header-y += mempolicy.h
diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
new file mode 100644
index 000..23b4090
--- /dev/null
+++ b/include/uapi/linux/media-bus-format.h
@@ -0,0 +1,125 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MEDIA_BUS_FORMAT_H
+#define __LINUX_MEDIA_BUS_FORMAT_H
+
+/*
+ * These bus formats uniquely identify data formats on the data bus. Format 0
+ * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where
+ * the data format is fixed. Additionally, 2X8 means that one pixel is
+ * transferred in two 8-bit samples, BE or LE specify in which order those
+ * samples are transferred over the bus: LE means that the least significant
+ * bits are transferred first, BE means that the most significant bits are
+ * transferred first, and PADHI and PADLO define which bits - low or high,
+ * in the incomplete high byte, are filled with padding bits.
+ *
+ * The bus formats are grouped by type, bus_width, bits per component, samples
+ * per pixel and order of subsamples. Numerical values are sorted using generic
+ * numerical sort order (8 thus comes before 10).
+ *
+ * As their value can't change when a new bus format is inserted in the
+ * enumeration, the bus formats are explicitly given a numerical value. The 
next
+ * free values for each category are listed below, update them when inserting
+ * new pixel codes.
+ */
+
+#define MEDIA_BUS_FMT_FIXED0x0001
+
+/* RGB - next is   0x100e */
+#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE  0x1001
+#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE  0x1002
+#define MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE  0x1003
+#define MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE  0x1004
+#define MEDIA_BUS_FMT_BGR565_2X8_BE0x1005
+#define MEDIA_BUS_FMT_BGR565_2X8_LE0x1006
+#define MEDIA_BUS_FMT_RGB565_2X8_BE0x1007
+#define MEDIA_BUS_FMT_RGB565_2X8_LE0x1008
+#define MEDIA_BUS_FMT_RGB666_1X18  0x1009
+#define MEDIA_BUS_FMT_RGB888_1X24  0x100a
+#define MEDIA_BUS_FMT_RGB888_2X12_BE   0x100b
+#define MEDIA_BUS_FMT_RGB888_2X12_LE   0x100c
+#define MEDIA_BUS_FMT_ARGB_1X320x100d
+
+/* YUV (including grey) - next is  0x2024 */
+#define MEDIA_BUS_FMT_Y8_1X8   0x2001
+#define MEDIA_BUS_FMT_UV8_1X8  0x2015
+#define MEDIA_BUS_FMT_UYVY8_1_5X8  0x2002
+#define MEDIA_BUS_FMT_VYUY8_1_5X8  0x2003
+#define MEDIA_BUS_FMT_YUYV8_1_5X8  0x2004
+#define MEDIA_BUS_FMT_YVYU8_1_5X8  0x2005
+#define MEDIA_BUS_FMT_UYVY8_2X80x2006
+#define MEDIA_BUS_FMT_VYUY8_2X80x2007
+#define MEDIA_BUS_FMT_YUYV8_2X80x2008
+#define MEDIA_BUS_FMT_YVYU8_2X80x2009
+#define MEDIA_BUS_FMT_Y10_1X10 0x200a
+#define MEDIA_BUS_FMT_UYVY10_2X10  0x2018
+#define MEDIA_BUS_FMT_VYUY10_2X10  0x2019
+#define MEDIA_BUS_FMT_YUYV10_2X10  0x200b
+#define MEDIA_BUS_FMT_YVYU10_2X10  0x200c
+#define MEDIA_BUS_FMT_Y12_1X12 0x2013
+#define MEDIA_BUS_FMT_UYVY8_1X16   0x200f
+#define MEDIA_BUS_FMT_VYUY8_1X16   0x2010
+#define MEDIA_BUS_FMT_YUYV8_1X16   0x2011
+#define MEDIA_BUS_FMT_YVYU8_1X16   0x2012
+#define MEDIA_BUS_FMT_YDYUYDYV8_1X16   0x2014
+#define MEDIA_BUS_FMT_UYVY10_1X20

[PATCH] mtd: nand: pass page number to ecc-write_xxx() methods

2015-08-24 Thread Boris Brezillon
The -read_xxx() methods are all passed the page number the NAND controller
is supposed to read, but -write_xxx() do not have such a parameter.

This is a problem if we want to properly implement data
scrambling/randomization in order to mitigate MLC sensibility to repeated
pattern: to prevent bitflips in adjacent pages in the same block we need
to avoid repeating the same pattern at the same offset in those pages,
hence the randomizer/scrambler engine need to be passed the page value
in order to adapt its seed accordingly.

Moreover, adding the page parameter the -write_xxx() methods add some
consistency to the current model.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
CC: Josh Wu josh...@atmel.com
CC: Ezequiel Garcia ezequiel.gar...@free-electrons.com
CC: Maxime Ripard maxime.rip...@free-electrons.com
CC: Greg Kroah-Hartman gre...@linuxfoundation.org
CC: Huang Shijie shijie.hu...@intel.com
CC: Bryan Wu bryan...@analog.com
CC: de...@driverdev.osuosl.org
CC: linux-arm-ker...@lists.infradead.org
CC: linux-ker...@vger.kernel.org

---
 drivers/mtd/nand/atmel_nand.c |  6 --
 drivers/mtd/nand/bf5xx_nand.c |  3 ++-
 drivers/mtd/nand/brcmnand/brcmnand.c  |  4 ++--
 drivers/mtd/nand/cafe_nand.c  |  3 ++-
 drivers/mtd/nand/denali.c |  5 +++--
 drivers/mtd/nand/docg4.c  |  4 ++--
 drivers/mtd/nand/fsl_elbc_nand.c  |  4 ++--
 drivers/mtd/nand/fsl_ifc_nand.c   |  2 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c|  6 +++---
 drivers/mtd/nand/hisi504_nand.c   |  3 ++-
 drivers/mtd/nand/lpc32xx_mlc.c|  3 ++-
 drivers/mtd/nand/lpc32xx_slc.c|  5 +++--
 drivers/mtd/nand/nand_base.c  | 31 ++-
 drivers/mtd/nand/omap2.c  |  3 ++-
 drivers/mtd/nand/pxa3xx_nand.c|  3 ++-
 drivers/mtd/nand/sh_flctl.c   |  3 ++-
 drivers/mtd/nand/sunxi_nand.c |  5 +++--
 drivers/staging/mt29f_spinand/mt29f_spinand.c |  3 ++-
 include/linux/mtd/nand.h  |  6 +++---
 19 files changed, 63 insertions(+), 39 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 46010bd..d0f50c9 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -954,7 +954,8 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
 }
 
 static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
-   struct nand_chip *chip, const uint8_t *buf, int oob_required)
+   struct nand_chip *chip, const uint8_t *buf, int oob_required,
+   int page)
 {
struct atmel_nand_host *host = chip-priv;
uint32_t *eccpos = chip-ecc.layout-eccpos;
@@ -2005,7 +2006,8 @@ static int nfc_sram_write_page(struct mtd_info *mtd, 
struct nand_chip *chip,
 
if (likely(!raw))
/* Need to write ecc into oob */
-   status = chip-ecc.write_page(mtd, chip, buf, oob_required);
+   status = chip-ecc.write_page(mtd, chip, buf, oob_required,
+ page);
 
if (status  0)
return status;
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index 4d8d4ba..17b3727 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -566,7 +566,8 @@ static int bf5xx_nand_read_page_raw(struct mtd_info *mtd, 
struct nand_chip *chip
 }
 
 static int bf5xx_nand_write_page_raw(struct mtd_info *mtd,
-   struct nand_chip *chip, const uint8_t *buf, int oob_required)
+   struct nand_chip *chip, const uint8_t *buf, int oob_required,
+   int page)
 {
bf5xx_nand_write_buf(mtd, buf, mtd-writesize);
bf5xx_nand_write_buf(mtd, chip-oob_poi, mtd-oobsize);
diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c 
b/drivers/mtd/nand/brcmnand/brcmnand.c
index fddb795..9a4e345 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -1606,7 +1606,7 @@ out:
 }
 
 static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-  const uint8_t *buf, int oob_required)
+  const uint8_t *buf, int oob_required, int page)
 {
struct brcmnand_host *host = chip-priv;
void *oob = oob_required ? chip-oob_poi : NULL;
@@ -1617,7 +1617,7 @@ static int brcmnand_write_page(struct mtd_info *mtd, 
struct nand_chip *chip,
 
 static int brcmnand_write_page_raw(struct mtd_info *mtd,
   struct nand_chip *chip, const uint8_t *buf,
-  int oob_required)
+  int oob_required, int page)
 {
struct brcmnand_host *host = chip-priv;
void *oob = oob_required ? chip-oob_poi : NULL;
diff --git a/drivers/mtd/nand/cafe_nand.c b

[PATCH 09/27] mtd: nand: make use of mtd_to_nand() in NAND core code

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct access to the
mtd->priv field. Update core code to use mtd_to_nand().

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/mtd/nand/nand_base.c | 84 ++--
 drivers/mtd/nand/nand_bbt.c  | 32 -
 drivers/mtd/nand/nand_bch.c  |  4 +--
 drivers/mtd/nand/nand_ecc.c  |  4 +--
 drivers/mtd/nand/nandsim.c   | 18 +-
 5 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 4ac4efe..71cc029 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -106,7 +106,7 @@ DEFINE_LED_TRIGGER(nand_led_trigger);
 static int check_offs_len(struct mtd_info *mtd,
loff_t ofs, uint64_t len)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
int ret = 0;
 
/* Start address must align on block boundary */
@@ -132,7 +132,7 @@ static int check_offs_len(struct mtd_info *mtd,
  */
 static void nand_release_device(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
/* Release the controller and the chip */
spin_lock(>controller->lock);
@@ -150,7 +150,7 @@ static void nand_release_device(struct mtd_info *mtd)
  */
 static uint8_t nand_read_byte(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
return readb(chip->IO_ADDR_R);
 }
 
@@ -163,7 +163,7 @@ static uint8_t nand_read_byte(struct mtd_info *mtd)
  */
 static uint8_t nand_read_byte16(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
return (uint8_t) cpu_to_le16(readw(chip->IO_ADDR_R));
 }
 
@@ -175,7 +175,7 @@ static uint8_t nand_read_byte16(struct mtd_info *mtd)
  */
 static u16 nand_read_word(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
return readw(chip->IO_ADDR_R);
 }
 
@@ -188,7 +188,7 @@ static u16 nand_read_word(struct mtd_info *mtd)
  */
 static void nand_select_chip(struct mtd_info *mtd, int chipnr)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
switch (chipnr) {
case -1:
@@ -211,7 +211,7 @@ static void nand_select_chip(struct mtd_info *mtd, int 
chipnr)
  */
 static void nand_write_byte(struct mtd_info *mtd, uint8_t byte)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
chip->write_buf(mtd, , 1);
 }
@@ -225,7 +225,7 @@ static void nand_write_byte(struct mtd_info *mtd, uint8_t 
byte)
  */
 static void nand_write_byte16(struct mtd_info *mtd, uint8_t byte)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
uint16_t word = byte;
 
/*
@@ -257,7 +257,7 @@ static void nand_write_byte16(struct mtd_info *mtd, uint8_t 
byte)
  */
 static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
iowrite8_rep(chip->IO_ADDR_W, buf, len);
 }
@@ -272,7 +272,7 @@ static void nand_write_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)
  */
 static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
ioread8_rep(chip->IO_ADDR_R, buf, len);
 }
@@ -287,7 +287,7 @@ static void nand_read_buf(struct mtd_info *mtd, uint8_t 
*buf, int len)
  */
 static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
u16 *p = (u16 *) buf;
 
iowrite16_rep(chip->IO_ADDR_W, p, len >> 1);
@@ -303,7 +303,7 @@ static void nand_write_buf16(struct mtd_info *mtd, const 
uint8_t *buf, int len)
  */
 static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
u16 *p = (u16 *) buf;
 
ioread16_rep(chip->IO_ADDR_R, p, len >> 1);
@@ -320,7 +320,7 @@ static void nand_read_buf16(struct mtd_info *mtd, uint8_t 
*buf, int len)
 static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
 {
int page, chipnr, res = 0, i = 0;
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
u16 bad;
 
if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
@@ -380,7 +380,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_

[PATCH 13/27] mtd: nand: add nand_to_mtd() helper

2015-11-16 Thread Boris Brezillon
Add a new helper to retrieve the MTD device attached to a NAND chip.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 include/linux/mtd/nand.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index c4e39ff..8ec071e 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -737,6 +737,11 @@ static inline struct nand_chip *mtd_to_nand(struct 
mtd_info *mtd)
return mtd->priv;
 }
 
+static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip)
+{
+   return >mtd;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/27] sh: nand: make use of mtd_to_nand() where appropriate

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all SH specific implementations to use this
helper.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 arch/sh/boards/mach-migor/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/boards/mach-migor/setup.c 
b/arch/sh/boards/mach-migor/setup.c
index 29b7c0d..8673f91 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -167,7 +167,7 @@ static struct mtd_partition migor_nand_flash_partitions[] = 
{
 static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
 unsigned int ctrl)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
if (cmd == NAND_CMD_NONE)
return;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/27] mips: nand: make use of mtd_to_nand() where appropriate

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all MIPS specific implementations to use this
helper.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 arch/mips/alchemy/devboards/db1200.c | 2 +-
 arch/mips/alchemy/devboards/db1300.c | 2 +-
 arch/mips/alchemy/devboards/db1550.c | 2 +-
 arch/mips/pnx833x/common/platform.c  | 2 +-
 arch/mips/rb532/devices.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/alchemy/devboards/db1200.c 
b/arch/mips/alchemy/devboards/db1200.c
index 8c13675..992442a 100644
--- a/arch/mips/alchemy/devboards/db1200.c
+++ b/arch/mips/alchemy/devboards/db1200.c
@@ -200,7 +200,7 @@ static struct i2c_board_info db1200_i2c_devs[] __initdata = 
{
 static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
 unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
 
ioaddr &= 0xff00;
diff --git a/arch/mips/alchemy/devboards/db1300.c 
b/arch/mips/alchemy/devboards/db1300.c
index b580770..d3c087f 100644
--- a/arch/mips/alchemy/devboards/db1300.c
+++ b/arch/mips/alchemy/devboards/db1300.c
@@ -150,7 +150,7 @@ static void __init db1300_gpio_config(void)
 static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
 unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
 
ioaddr &= 0xff00;
diff --git a/arch/mips/alchemy/devboards/db1550.c 
b/arch/mips/alchemy/devboards/db1550.c
index 5740bcf..b518f02 100644
--- a/arch/mips/alchemy/devboards/db1550.c
+++ b/arch/mips/alchemy/devboards/db1550.c
@@ -128,7 +128,7 @@ static struct i2c_board_info db1550_i2c_devs[] __initdata = 
{
 static void au1550_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
 unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
 
ioaddr &= 0xff00;
diff --git a/arch/mips/pnx833x/common/platform.c 
b/arch/mips/pnx833x/common/platform.c
index b4b774b..3cd3577 100644
--- a/arch/mips/pnx833x/common/platform.c
+++ b/arch/mips/pnx833x/common/platform.c
@@ -180,7 +180,7 @@ static struct platform_device pnx833x_sata_device = {
 static void
 pnx833x_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
 
if (cmd == NAND_CMD_NONE)
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 9bd7a2d..0966adc 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -148,7 +148,7 @@ static int rb532_dev_ready(struct mtd_info *mtd)
 
 static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
unsigned char orbits, nandbits;
 
if (ctrl & NAND_CTRL_CHANGE) {
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/27] mtd: nand: add an mtd_to_nand() helper

2015-11-16 Thread Boris Brezillon
Some drivers are retrieving the nand_chip pointer using the container_of
macro on a struct wrapping both the nand_chip and the mtd_info struct while
the standard way of retrieving this pointer is through mtd->priv.
Provide an helper to do that.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 include/linux/mtd/nand.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 4f7c9b9..056d165 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -730,6 +730,11 @@ static inline struct device_node 
*nand_get_flash_node(struct nand_chip *chip)
return chip->flash_node;
 }
 
+static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd)
+{
+   return mtd->priv;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/27] mtd: nand: update examples in the documentation to use mtd_to_nand()

2015-11-16 Thread Boris Brezillon
mtd_to_nand() has been introduced to hide accesses to mtd->priv.
All NAND controller drivers should use it instead of directly accessing
the ->priv field.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 Documentation/DocBook/mtdnand.tmpl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/mtdnand.tmpl 
b/Documentation/DocBook/mtdnand.tmpl
index 7da8f04..403a7ab 100644
--- a/Documentation/DocBook/mtdnand.tmpl
+++ b/Documentation/DocBook/mtdnand.tmpl
@@ -235,7 +235,7 @@ static void board_hwcontrol(struct mtd_info *mtd, int cmd)

 static void board_hwcontrol(struct mtd_info *mtd, int cmd)
 {
-   struct nand_chip *this = (struct nand_chip *) mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
switch(cmd){
case NAND_CTL_SETCLE: this->IO_ADDR_W |= CLE_ADRR_BIT;  break;
case NAND_CTL_CLRCLE: this->IO_ADDR_W = ~CLE_ADRR_BIT; 
break;
@@ -399,7 +399,7 @@ static void board_select_chip (struct mtd_info *mtd, int 
chip)

 static void board_select_chip (struct mtd_info *mtd, int chip)
 {
-   struct nand_chip *this = (struct nand_chip *) mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);

/* Deselect all chips */
this->IO_ADDR_R = ~BOARD_NAND_ADDR_MASK;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/27] cris: nand: make use of mtd_to_nand() where appropriate

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all CRIS specific implementations to use this
helper.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 2 +-
 arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c 
b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index 7fb5212..db953cf 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -52,7 +52,7 @@ static void crisv32_hwcontrol(struct mtd_info *mtd, int cmd,
 {
unsigned long flags;
reg_pio_rw_dout dout;
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
 
local_irq_save(flags);
 
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c 
b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index e032384..22a6467 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -51,7 +51,7 @@ static void crisv32_hwcontrol(struct mtd_info *mtd, int cmd,
 {
unsigned long flags;
reg_gio_rw_pa_dout dout;
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
 
local_irq_save(flags);
 
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/27] ARM: nand: make use of mtd_to_nand() where appropriate

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all ARM specific implementations to use this
helper.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 arch/arm/mach-ep93xx/snappercl15.c   | 4 ++--
 arch/arm/mach-ep93xx/ts72xx.c| 4 ++--
 arch/arm/mach-imx/mach-qong.c| 2 +-
 arch/arm/mach-ixp4xx/ixdp425-setup.c | 2 +-
 arch/arm/mach-omap1/board-nand.c | 2 +-
 arch/arm/mach-orion5x/ts78xx-setup.c | 6 +++---
 arch/arm/mach-pxa/balloon3.c | 2 +-
 arch/arm/mach-pxa/em-x270.c  | 2 +-
 arch/arm/mach-pxa/palmtx.c   | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-ep93xx/snappercl15.c 
b/arch/arm/mach-ep93xx/snappercl15.c
index c490426..b2db791 100644
--- a/arch/arm/mach-ep93xx/snappercl15.c
+++ b/arch/arm/mach-ep93xx/snappercl15.c
@@ -49,7 +49,7 @@
 static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  unsigned int ctrl)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
static u16 nand_state = SNAPPERCL15_NAND_WPN;
u16 set;
 
@@ -76,7 +76,7 @@ static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, 
int cmd,
 
 static int snappercl15_nand_dev_ready(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);
 }
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index 61f4b5d..45b81a2 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -74,7 +74,7 @@ static void __init ts72xx_map_io(void)
 static void ts72xx_nand_hwcontrol(struct mtd_info *mtd,
  int cmd, unsigned int ctrl)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
 
if (ctrl & NAND_CTRL_CHANGE) {
void __iomem *addr = chip->IO_ADDR_R;
@@ -96,7 +96,7 @@ static void ts72xx_nand_hwcontrol(struct mtd_info *mtd,
 
 static int ts72xx_nand_device_ready(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
void __iomem *addr = chip->IO_ADDR_R;
 
addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE);
diff --git a/arch/arm/mach-imx/mach-qong.c b/arch/arm/mach-imx/mach-qong.c
index a213e7b..5c27646 100644
--- a/arch/arm/mach-imx/mach-qong.c
+++ b/arch/arm/mach-imx/mach-qong.c
@@ -131,7 +131,7 @@ static void qong_init_nor_mtd(void)
  */
 static void qong_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int 
ctrl)
 {
-   struct nand_chip *nand_chip = mtd->priv;
+   struct nand_chip *nand_chip = mtd_to_nand(mtd);
 
if (cmd == NAND_CMD_NONE)
return;
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c 
b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index e7b8bef..333b0f9 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -76,7 +76,7 @@ static struct mtd_partition ixdp425_partitions[] = {
 static void
 ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
int offset = (int)this->priv;
 
if (ctrl & NAND_CTRL_CHANGE) {
diff --git a/arch/arm/mach-omap1/board-nand.c b/arch/arm/mach-omap1/board-nand.c
index 4d08353..7684f92 100644
--- a/arch/arm/mach-omap1/board-nand.c
+++ b/arch/arm/mach-omap1/board-nand.c
@@ -22,7 +22,7 @@
 
 void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
unsigned long mask;
 
if (cmd == NAND_CMD_NONE)
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c 
b/arch/arm/mach-orion5x/ts78xx-setup.c
index 1b704d3..96cf6b5 100644
--- a/arch/arm/mach-orion5x/ts78xx-setup.c
+++ b/arch/arm/mach-orion5x/ts78xx-setup.c
@@ -176,7 +176,7 @@ static void ts78xx_ts_rtc_unload(void)
 static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
 
if (ctrl & NAND_CTRL_CHANGE) {
unsigned char bits;
@@ -200,7 +200,7 @@ static int ts78xx_ts_nand_dev_ready(struct mtd_info *mtd)
 static void ts78xx_ts_nand_write_buf(struct mtd_info *mtd,
const uint8_t *buf, int len)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
void __iomem *io_base = chip->IO_ADDR_W;
unsigned long off = ((unsigned long)buf & 3);
int sz;
@@ -227,7 +227,7 @@ static void ts78xx_ts_nand_write_buf(struc

[PATCH 00/27] mtd: nand: refactor the NAND subsystem (part 1)

2015-11-16 Thread Boris Brezillon
Hello,

This huge series aims at clarifying the relationship between the mtd and
nand_chip structures and hiding NAND framework internals to NAND
controller drivers.

The first part of the series provide an mtd_to_nand() helper to hide the
way mtd and nand_chip are linked together.

The second part of the series embeds the mtd structure into the nand_chip
one so that NAND controller drivers don't have to bother allocating the
MTD device and linking it with the NAND chip.

The last part of the series hides accesses to the chip->priv field behind
two helper functions.

This allows removal of some of the boilerplate code done in all NAND
controller drivers, but most importantly, it unifies a bit the way NAND
chip structures are instantiated (even though we still have two different
kinds of drivers: those embedding the nand_chip struct into their private
nand chip representation, and those allocating two different structures
and linking them together with the chip->priv field).

As said in the title, this refactoring is only the first step. I plan to
rework the NAND controller / NAND chip separation for pretty much the same
reasons: clarifying the separation between the two concepts, and getting
rid of more boilerplate code in NAND controller drivers.

Stay tuned ;-).

Best Regards,

Boris

Boris Brezillon (27):
  mtd: nand: fix drivers abusing mtd->priv
  mtd: nand: add an mtd_to_nand() helper
  mtd: nand: update examples in the documentation to use mtd_to_nand()
  ARM: nand: make use of mtd_to_nand() where appropriate
  blackfin: nand: make use of mtd_to_nand() where appropriate
  cris: nand: make use of mtd_to_nand() where appropriate
  mips: nand: make use of mtd_to_nand() where appropriate
  sh: nand: make use of mtd_to_nand() where appropriate
  mtd: nand: make use of mtd_to_nand() in NAND core code
  mtd: nand: make use of mtd_to_nand() in NAND drivers
  staging: mt29f_spinand: make use of mtd_to_nand()
  mtd: nand: embed an mtd_info structure into nand_chip
  mtd: nand: add nand_to_mtd() helper
  mtd: nand: use the mtd instance embedded in struct nand_chip
  mtd: nand: update the documentation to reflect framework changes
  staging: mt29f_spinand: use the mtd instance embedded in struct
nand_chip
  cris: nand: use the mtd instance embedded in struct nand_chip
  mtd: nand: update mtd_to_nand()
  mtd: nand: remove useless mtd->priv = chip assignments
  cris: nand: remove useless mtd->priv = chip assignments
  staging: mt29f_spinand: remove useless mtd->priv = chip assignment
  mtd: nand: simplify nand_dt_init() usage
  mtd: nand: kill the chip->flash_node field
  mtd: nand: add helpers to access ->priv
  ARM: make use of nand_set/get_controller_data() helpers
  mtd: nand: make use of nand_set/get_controller_data() helpers
  staging: mt29f_spinand: make use of nand_set/get_controller_data()
helpers

 Documentation/DocBook/mtdnand.tmpl |  35 +++---
 arch/arm/mach-ep93xx/snappercl15.c |   4 +-
 arch/arm/mach-ep93xx/ts72xx.c  |   4 +-
 arch/arm/mach-imx/mach-qong.c  |   2 +-
 arch/arm/mach-ixp4xx/ixdp425-setup.c   |   6 +-
 arch/arm/mach-omap1/board-nand.c   |   2 +-
 arch/arm/mach-orion5x/ts78xx-setup.c   |   6 +-
 arch/arm/mach-pxa/balloon3.c   |   2 +-
 arch/arm/mach-pxa/em-x270.c|   2 +-
 arch/arm/mach-pxa/palmtx.c |   2 +-
 arch/blackfin/mach-bf537/boards/stamp.c|   2 +-
 arch/blackfin/mach-bf561/boards/acvilon.c  |   2 +-
 arch/cris/arch-v32/drivers/mach-a3/nandflash.c |   8 +-
 arch/cris/arch-v32/drivers/mach-fs/nandflash.c |   8 +-
 arch/mips/alchemy/devboards/db1200.c   |   2 +-
 arch/mips/alchemy/devboards/db1300.c   |   2 +-
 arch/mips/alchemy/devboards/db1550.c   |   2 +-
 arch/mips/pnx833x/common/platform.c|   2 +-
 arch/mips/rb532/devices.c  |   2 +-
 arch/sh/boards/mach-migor/setup.c  |   2 +-
 drivers/mtd/nand/ams-delta.c   |  26 ++---
 drivers/mtd/nand/atmel_nand.c  | 116 ++-
 drivers/mtd/nand/au1550nd.c|  40 +++
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |   1 -
 drivers/mtd/nand/bcm47xxnflash/main.c  |   9 +-
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c   |  34 +++---
 drivers/mtd/nand/bf5xx_nand.c  |  27 +++--
 drivers/mtd/nand/brcmnand/brcmnand.c   |  54 +
 drivers/mtd/nand/cafe_nand.c   |  41 ---
 drivers/mtd/nand/cmx270_nand.c |  20 ++--
 drivers/mtd/nand/cs553x_nand.c |  30 +++--
 drivers/mtd/nand/davinci_nand.c|  33 +++---
 drivers/mtd/nand/denali.c  |  61 +-
 drivers/mtd/nand/denali.h  |   1 -
 drivers/mtd/nand/diskonchip.c  | 148 -
 drivers/mtd/nand/docg4.c

[PATCH 11/27] staging: mt29f_spinand: make use of mtd_to_nand()

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Use it where appropriate.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c 
b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index 6536066..8924a96 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -31,7 +31,7 @@
 
 static inline struct spinand_state *mtd_to_state(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = (struct nand_chip *)mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
struct spinand_info *info = (struct spinand_info *)chip->priv;
struct spinand_state *state = (struct spinand_state *)info->priv;
 
@@ -744,7 +744,7 @@ static void spinand_reset(struct spi_device *spi_nand)
 static void spinand_cmdfunc(struct mtd_info *mtd, unsigned int command,
int column, int page)
 {
-   struct nand_chip *chip = (struct nand_chip *)mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
struct spinand_info *info = (struct spinand_info *)chip->priv;
struct spinand_state *state = (struct spinand_state *)info->priv;
 
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/27] mtd: nand: use the mtd instance embedded in struct nand_chip

2015-11-16 Thread Boris Brezillon
struct nand_chip now embeds an mtd device. Patch all drivers to make use
of this mtd instance instead of using the instance embedded in their
private struct or dynamically allocated.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
Cc: Julia Lawall <julia.law...@lip6.fr>
---
Most of those changes were generate with this coccinelle script:
http://code.bulix.org/5vxuih-89429
---
 drivers/mtd/nand/ams-delta.c   | 13 ++--
 drivers/mtd/nand/atmel_nand.c  | 11 ++-
 drivers/mtd/nand/au1550nd.c| 18 ++---
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |  1 -
 drivers/mtd/nand/bcm47xxnflash/main.c  |  7 +-
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c   |  2 +-
 drivers/mtd/nand/bf5xx_nand.c  | 14 ++--
 drivers/mtd/nand/brcmnand/brcmnand.c   | 11 ++-
 drivers/mtd/nand/cafe_nand.c   | 10 +--
 drivers/mtd/nand/cmx270_nand.c | 11 ++-
 drivers/mtd/nand/cs553x_nand.c | 13 ++--
 drivers/mtd/nand/davinci_nand.c| 25 +++
 drivers/mtd/nand/denali.c  | 61 +
 drivers/mtd/nand/denali.h  |  1 -
 drivers/mtd/nand/diskonchip.c  | 11 ++-
 drivers/mtd/nand/docg4.c   | 18 +++--
 drivers/mtd/nand/fsl_elbc_nand.c   | 22 +++---
 drivers/mtd/nand/fsl_ifc_nand.c| 23 +++
 drivers/mtd/nand/fsl_upm.c | 26 +++
 drivers/mtd/nand/fsmc_nand.c   | 59 +---
 drivers/mtd/nand/gpio.c| 16 ++---
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |  2 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 20 +++---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.h |  1 -
 drivers/mtd/nand/hisi504_nand.c| 11 ++-
 drivers/mtd/nand/jz4740_nand.c |  9 ++-
 drivers/mtd/nand/lpc32xx_mlc.c |  7 +-
 drivers/mtd/nand/lpc32xx_slc.c |  7 +-
 drivers/mtd/nand/mpc5121_nfc.c |  3 +-
 drivers/mtd/nand/mxc_nand.c|  5 +-
 drivers/mtd/nand/nandsim.c | 12 ++--
 drivers/mtd/nand/ndfc.c| 22 +++---
 drivers/mtd/nand/nuc900_nand.c | 21 +++---
 drivers/mtd/nand/omap2.c   | 94 +++---
 drivers/mtd/nand/orion_nand.c  |  4 +-
 drivers/mtd/nand/pasemi_nand.c | 14 ++--
 drivers/mtd/nand/plat_nand.c   | 14 ++--
 drivers/mtd/nand/pxa3xx_nand.c | 33 -
 drivers/mtd/nand/r852.c| 34 --
 drivers/mtd/nand/r852.h|  1 -
 drivers/mtd/nand/s3c2410.c | 19 +++---
 drivers/mtd/nand/sh_flctl.c|  8 +--
 drivers/mtd/nand/sharpsl.c | 18 ++---
 drivers/mtd/nand/socrates_nand.c   |  5 +-
 drivers/mtd/nand/sunxi_nand.c  | 13 ++--
 drivers/mtd/nand/tmio_nand.c   |  7 +-
 drivers/mtd/nand/txx9ndfmc.c   |  3 +-
 drivers/mtd/nand/vf610_nfc.c   |  5 +-
 include/linux/mtd/sh_flctl.h   |  3 +-
 49 files changed, 383 insertions(+), 385 deletions(-)

diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index b2b49c4..0f638c6 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -183,19 +183,16 @@ static int ams_delta_init(struct platform_device *pdev)
return -ENXIO;
 
/* Allocate memory for MTD device structure and private data */
-   ams_delta_mtd = kzalloc(sizeof(struct mtd_info) +
-   sizeof(struct nand_chip), GFP_KERNEL);
-   if (!ams_delta_mtd) {
+   this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
+   if (!this) {
printk (KERN_WARNING "Unable to allocate E3 NAND MTD device 
structure.\n");
err = -ENOMEM;
goto out;
}
 
+   ams_delta_mtd = nand_to_mtd(this);
ams_delta_mtd->owner = THIS_MODULE;
 
-   /* Get pointer to private data */
-   this = (struct nand_chip *) (_delta_mtd[1]);
-
/* Link the private data with the MTD structure */
ams_delta_mtd->priv = this;
 
@@ -256,7 +253,7 @@ out_gpio:
gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
iounmap(io_base);
 out_free:
-   kfree(ams_delta_mtd);
+   kfree(this);
  out:
return err;
 }
@@ -276,7 +273,7 @@ static int ams_delta_cleanup(struct platform_device *pdev)
iounmap(io_base);
 
/* Free the MTD device structure */
-   kfree(ams_delta_mtd);
+   kfree(mtd_to_nand(ams_delta_mtd));
 
return 0;
 }
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index f8aac0a..51748b4 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/d

[PATCH 26/27] mtd: nand: make use of nand_set/get_controller_data() helpers

2015-11-16 Thread Boris Brezillon
New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/mtd/nand/ams-delta.c |  6 +--
 drivers/mtd/nand/atmel_nand.c| 54 ++---
 drivers/mtd/nand/bcm47xxnflash/main.c|  2 +-
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c | 16 +++
 drivers/mtd/nand/bf5xx_nand.c|  2 +-
 drivers/mtd/nand/brcmnand/brcmnand.c | 32 ++---
 drivers/mtd/nand/cafe_nand.c | 24 +-
 drivers/mtd/nand/diskonchip.c| 70 ++--
 drivers/mtd/nand/docg4.c | 42 -
 drivers/mtd/nand/fsl_elbc_nand.c | 22 -
 drivers/mtd/nand/fsl_ifc_nand.c  | 26 +--
 drivers/mtd/nand/fsmc_nand.c |  2 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c   | 28 +--
 drivers/mtd/nand/hisi504_nand.c  | 20 
 drivers/mtd/nand/lpc32xx_mlc.c   | 18 +++
 drivers/mtd/nand/lpc32xx_slc.c   | 20 
 drivers/mtd/nand/mpc5121_nfc.c   | 24 +-
 drivers/mtd/nand/mxc_nand.c  | 36 +++---
 drivers/mtd/nand/nandsim.c   |  4 +-
 drivers/mtd/nand/ndfc.c  | 16 +++
 drivers/mtd/nand/orion_nand.c|  4 +-
 drivers/mtd/nand/plat_nand.c |  2 +-
 drivers/mtd/nand/pxa3xx_nand.c   | 22 -
 drivers/mtd/nand/r852.c  |  6 +--
 drivers/mtd/nand/s3c2410.c   |  4 +-
 drivers/mtd/nand/socrates_nand.c | 10 ++--
 drivers/mtd/nand/txx9ndfmc.c |  8 ++--
 27 files changed, 260 insertions(+), 260 deletions(-)

diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 1a18938..68b58c8 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -65,7 +65,7 @@ static struct mtd_partition partition_info[] = {
 static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
 {
struct nand_chip *this = mtd_to_nand(mtd);
-   void __iomem *io_base = this->priv;
+   void __iomem *io_base = (void __iomem *)nand_get_controller_data(this);
 
writew(0, io_base + OMAP_MPUIO_IO_CNTL);
writew(byte, this->IO_ADDR_W);
@@ -78,7 +78,7 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd)
 {
u_char res;
struct nand_chip *this = mtd_to_nand(mtd);
-   void __iomem *io_base = this->priv;
+   void __iomem *io_base = (void __iomem *)nand_get_controller_data(this);
 
gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
ndelay(40);
@@ -206,7 +206,7 @@ static int ams_delta_init(struct platform_device *pdev)
goto out_free;
}
 
-   this->priv = io_base;
+   nand_set_controller_data(this, (void *)io_base);
 
/* Set address of NAND IO lines */
this->IO_ADDR_R = io_base + OMAP_MPUIO_INPUT_LATCH;
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index aef02d3..769ad8b 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -182,7 +182,7 @@ static void atmel_nand_disable(struct atmel_nand_host *host)
 static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int 
ctrl)
 {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
-   struct atmel_nand_host *host = nand_chip->priv;
+   struct atmel_nand_host *host = nand_get_controller_data(nand_chip);
 
if (ctrl & NAND_CTRL_CHANGE) {
if (ctrl & NAND_NCE)
@@ -205,7 +205,7 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int 
cmd, unsigned int ctrl
 static int atmel_nand_device_ready(struct mtd_info *mtd)
 {
struct nand_chip *nand_chip = mtd_to_nand(mtd);
-   struct atmel_nand_host *host = nand_chip->priv;
+   struct atmel_nand_host *host = nand_get_controller_data(nand_chip);
 
return gpio_get_value(host->board.rdy_pin) ^
 !!host->board.rdy_pin_active_low;
@@ -215,7 +215,7 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
 static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd)
 {
struct nand_chip *chip = mtd_to_nand(mtd);
-   struct atmel_nand_host *host = chip->priv;
+   struct atmel_nand_host *host = nand_get_controller_data(chip);
int res = 0;
 
if (gpio_is_valid(host->board.rdy_pin)) {
@@ -267,7 +267,7 @@ static int atmel_nand_set_enable_ready_pins(struct mtd_info 
*mtd)
 static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
 {
struct nand_chip*nand_chip = mtd_to_nand(mtd);
-   struct atmel_nand_host *host = nand_chip->priv;
+   struct atmel_nand_host *host = nand_get_controller_data(nand_chip);
 
if (host->n

[PATCH 24/27] mtd: nand: add helpers to access ->priv

2015-11-16 Thread Boris Brezillon
Add two helpers to access the field reserved for private controller data.
This makes it clearer what this field is reserved for and ease future
refactoring.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 include/linux/mtd/nand.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index f12efe1..4afa263 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -739,6 +739,16 @@ static inline struct mtd_info *nand_to_mtd(struct 
nand_chip *chip)
return >mtd;
 }
 
+static inline void *nand_get_controller_data(struct nand_chip *chip)
+{
+   return chip->priv;
+}
+
+static inline void nand_set_controller_data(struct nand_chip *chip, void *priv)
+{
+   chip->priv = priv;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 21/27] staging: mt29f_spinand: remove useless mtd->priv = chip assignment

2015-11-16 Thread Boris Brezillon
mtd_to_nand_chip() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
Patch generated with the following coccinelle script:

---8<
virtual patch

@@
struct mtd_info mtd;
struct mtd_info *mtdptr;
struct nand_chip *chipptr;
expression d;
@@
(
-(mtd).priv = (chipptr);
|
-(mtdptr)->priv = (chipptr);
---8<
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c 
b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index 8171b74..b7d429d 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -907,7 +907,6 @@ static int spinand_probe(struct spi_device *spi_nand)
 
dev_set_drvdata(_nand->dev, mtd);
 
-   mtd->priv = chip;
mtd->dev.parent = _nand->dev;
mtd->oobsize = 64;
 
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/27] mtd: nand: make use of mtd_to_nand() in NAND drivers

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all NAND drivers to use it.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/mtd/nand/ams-delta.c |  4 +-
 drivers/mtd/nand/atmel_nand.c| 50 ++---
 drivers/mtd/nand/au1550nd.c  | 22 +-
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c | 16 +++
 drivers/mtd/nand/bf5xx_nand.c| 12 ++---
 drivers/mtd/nand/brcmnand/brcmnand.c | 10 ++---
 drivers/mtd/nand/cafe_nand.c | 18 
 drivers/mtd/nand/cmx270_nand.c   |  8 ++--
 drivers/mtd/nand/cs553x_nand.c   | 16 +++
 drivers/mtd/nand/davinci_nand.c  |  8 ++--
 drivers/mtd/nand/diskonchip.c| 66 ++--
 drivers/mtd/nand/docg4.c | 34 +++---
 drivers/mtd/nand/fsl_elbc_nand.c | 14 +++---
 drivers/mtd/nand/fsl_ifc_nand.c  | 18 
 drivers/mtd/nand/fsl_upm.c   |  4 +-
 drivers/mtd/nand/fsmc_nand.c | 10 ++---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c   | 18 
 drivers/mtd/nand/hisi504_nand.c  | 16 +++
 drivers/mtd/nand/jz4740_nand.c   |  4 +-
 drivers/mtd/nand/lpc32xx_mlc.c   |  6 +--
 drivers/mtd/nand/lpc32xx_slc.c   | 14 +++---
 drivers/mtd/nand/mpc5121_nfc.c   | 24 +-
 drivers/mtd/nand/mxc_nand.c  | 34 +++---
 drivers/mtd/nand/ndfc.c  | 14 +++---
 drivers/mtd/nand/nuc900_nand.c   |  2 +-
 drivers/mtd/nand/omap2.c | 12 ++---
 drivers/mtd/nand/orion_nand.c|  4 +-
 drivers/mtd/nand/pasemi_nand.c   |  6 +--
 drivers/mtd/nand/pxa3xx_nand.c   | 20 -
 drivers/mtd/nand/r852.c  |  2 +-
 drivers/mtd/nand/s3c2410.c   |  6 +--
 drivers/mtd/nand/sharpsl.c   |  2 +-
 drivers/mtd/nand/sm_common.c |  2 +-
 drivers/mtd/nand/socrates_nand.c |  8 ++--
 drivers/mtd/nand/sunxi_nand.c| 26 +--
 drivers/mtd/nand/tmio_nand.c |  2 +-
 drivers/mtd/nand/txx9ndfmc.c | 12 ++---
 drivers/mtd/nand/xway_nand.c |  4 +-
 38 files changed, 274 insertions(+), 274 deletions(-)

diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 842f8fe..b2b49c4 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -64,7 +64,7 @@ static struct mtd_partition partition_info[] = {
 
 static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
void __iomem *io_base = this->priv;
 
writew(0, io_base + OMAP_MPUIO_IO_CNTL);
@@ -77,7 +77,7 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char 
byte)
 static u_char ams_delta_read_byte(struct mtd_info *mtd)
 {
u_char res;
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
void __iomem *io_base = this->priv;
 
gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 6ecc1c1..f8aac0a 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -182,7 +182,7 @@ static void atmel_nand_disable(struct atmel_nand_host *host)
  */
 static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int 
ctrl)
 {
-   struct nand_chip *nand_chip = mtd->priv;
+   struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct atmel_nand_host *host = nand_chip->priv;
 
if (ctrl & NAND_CTRL_CHANGE) {
@@ -205,7 +205,7 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int 
cmd, unsigned int ctrl
  */
 static int atmel_nand_device_ready(struct mtd_info *mtd)
 {
-   struct nand_chip *nand_chip = mtd->priv;
+   struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct atmel_nand_host *host = nand_chip->priv;
 
return gpio_get_value(host->board.rdy_pin) ^
@@ -215,7 +215,7 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
 /* Set up for hardware ready pin and enable pin. */
 static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd)
 {
-   struct nand_chip *chip = mtd->priv;
+   struct nand_chip *chip = mtd_to_nand(mtd);
struct atmel_nand_host *host = chip->priv;
int res = 0;
 
@@ -267,7 +267,7 @@ static int atmel_nand_set_enable_ready_pins(struct mtd_info 
*mtd)
  */
 static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
 {
-   struct nand_chip*nand_chip = mtd->priv;
+   struct nand_chip*nand_chip = mtd_to_nand(mtd);
 

[PATCH 15/27] mtd: nand: update the documentation to reflect framework changes

2015-11-16 Thread Boris Brezillon
The MTD device is now directly embedded in the nand_chip struct. Update the
mtdnand documentation to mention this aspect and fix the different
examples.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 Documentation/DocBook/mtdnand.tmpl | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/Documentation/DocBook/mtdnand.tmpl 
b/Documentation/DocBook/mtdnand.tmpl
index 403a7ab..b442921 100644
--- a/Documentation/DocBook/mtdnand.tmpl
+++ b/Documentation/DocBook/mtdnand.tmpl
@@ -162,12 +162,15 @@

Basic defines

-   At least you have to provide a mtd structure and
-   a storage for the ioremap'ed chip address.
-   You can allocate the mtd structure using kmalloc
-   or you can allocate it statically.
-   In case of static allocation you have to allocate
-   a nand_chip structure too.
+   At least you have to provide a nand_chip structure
+   and a storage for the ioremap'ed chip address.
+   You can allocate the nand_chip structure using
+   kmalloc or you can allocate it statically.
+   The NAND chip structure embeds an mtd structure
+   which will be registered to the MTD subsystem.
+   You can extract a pointer to the mtd structure
+   from a nand_chip pointer using the nand_to_mtd()
+   helper.


Kmalloc based example
@@ -180,7 +183,6 @@ static void __iomem *baseaddr;
Static example


-static struct mtd_info board_mtd;
 static struct nand_chip board_chip;
 static void __iomem *baseaddr;

@@ -274,13 +276,15 @@ static int __init board_init (void)
int err = 0;
 
/* Allocate memory for MTD device structure and private data */
-   board_mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), 
GFP_KERNEL);
-   if (!board_mtd) {
+   this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
+   if (!this) {
printk ("Unable to allocate NAND MTD device structure.\n");
err = -ENOMEM;
goto out;
}
 
+   board_mtd = nand_to_mtd(this);
+
/* map physical address */
baseaddr = ioremap(CHIP_PHYSICAL_ADDRESS, 1024);
if (!baseaddr) {
@@ -289,11 +293,6 @@ static int __init board_init (void)
goto out_mtd;
}
 
-   /* Get pointer to private data */
-   this = (struct nand_chip *) ();
-   /* Link the private data with the MTD structure */
-   board_mtd->priv = this;
-
/* Set address of NAND IO lines */
this->IO_ADDR_R = baseaddr;
this->IO_ADDR_W = baseaddr;
@@ -317,7 +316,7 @@ static int __init board_init (void)
 out_ior:
iounmap(baseaddr);
 out_mtd:
-   kfree (board_mtd);
+   kfree (this);
 out:
return err;
 }
@@ -343,7 +342,7 @@ static void __exit board_cleanup (void)
iounmap(baseaddr);

/* Free the MTD device structure */
-   kfree (board_mtd);
+   kfree (mtd_to_nand(board_mtd));
 }
 module_exit(board_cleanup);
 #endif
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/27] cris: nand: remove useless mtd->priv = chip assignments

2015-11-16 Thread Boris Brezillon
mtd_to_nand_chip() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
Patch generated with the following coccinelle script:

---8<
virtual patch

@@
struct mtd_info mtd;
struct mtd_info *mtdptr;
struct nand_chip *chipptr;
expression d;
@@
(
-(mtd).priv = (chipptr);
|
-(mtdptr)->priv = (chipptr);
---8<
---
 arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 3 ---
 arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c 
b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index ad78b97..2f65261 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -149,9 +149,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
this = >chip;
crisv32_mtd = nand_to_mtd(>chip);
 
-   /* Link the private data with the MTD structure */
-   crisv32_mtd->priv = this;
-
/* Set address of NAND IO lines */
this->IO_ADDR_R = read_cs;
this->IO_ADDR_W = write_cs;
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c 
b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index 00a277b..4ab9d4e 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -140,9 +140,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
bif_cfg.gated_csp1 = regk_bif_core_wr;
REG_WR(bif_core, regi_bif_core, rw_grp3_cfg, bif_cfg);
 
-   /* Link the private data with the MTD structure */
-   crisv32_mtd->priv = this;
-
/* Set address of NAND IO lines */
this->IO_ADDR_R = read_cs;
this->IO_ADDR_W = write_cs;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/27] mtd: nand: remove useless mtd->priv = chip assignments

2015-11-16 Thread Boris Brezillon
mtd_to_nand_chip() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
Patch generated with the following coccinelle script:

---8<
virtual patch

@@
struct mtd_info mtd;
struct mtd_info *mtdptr;
struct nand_chip *chipptr;
expression d;
@@
(
-(mtd).priv = (chipptr);
|
-(mtdptr)->priv = (chipptr);
---8<
---
 drivers/mtd/nand/ams-delta.c   | 3 ---
 drivers/mtd/nand/atmel_nand.c  | 1 -
 drivers/mtd/nand/bf5xx_nand.c  | 1 -
 drivers/mtd/nand/brcmnand/brcmnand.c   | 1 -
 drivers/mtd/nand/cafe_nand.c   | 1 -
 drivers/mtd/nand/cmx270_nand.c | 1 -
 drivers/mtd/nand/cs553x_nand.c | 1 -
 drivers/mtd/nand/diskonchip.c  | 1 -
 drivers/mtd/nand/docg4.c   | 1 -
 drivers/mtd/nand/fsmc_nand.c   | 1 -
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 1 -
 drivers/mtd/nand/hisi504_nand.c| 1 -
 drivers/mtd/nand/jz4740_nand.c | 1 -
 drivers/mtd/nand/lpc32xx_mlc.c | 1 -
 drivers/mtd/nand/lpc32xx_slc.c | 1 -
 drivers/mtd/nand/mpc5121_nfc.c | 1 -
 drivers/mtd/nand/mxc_nand.c| 1 -
 drivers/mtd/nand/omap2.c   | 1 -
 drivers/mtd/nand/orion_nand.c  | 1 -
 drivers/mtd/nand/pasemi_nand.c | 1 -
 drivers/mtd/nand/pxa3xx_nand.c | 1 -
 drivers/mtd/nand/r852.c| 1 -
 drivers/mtd/nand/sh_flctl.c| 1 -
 drivers/mtd/nand/socrates_nand.c   | 1 -
 drivers/mtd/nand/sunxi_nand.c  | 1 -
 drivers/mtd/nand/tmio_nand.c   | 1 -
 drivers/mtd/nand/txx9ndfmc.c   | 2 --
 drivers/mtd/nand/vf610_nfc.c   | 1 -
 28 files changed, 31 deletions(-)

diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 0f638c6..1a18938 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -193,9 +193,6 @@ static int ams_delta_init(struct platform_device *pdev)
ams_delta_mtd = nand_to_mtd(this);
ams_delta_mtd->owner = THIS_MODULE;
 
-   /* Link the private data with the MTD structure */
-   ams_delta_mtd->priv = this;
-
/*
 * Don't try to request the memory region from here,
 * it should have been already requested from the
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 51748b4..aef02d3 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -2126,7 +2126,6 @@ static int atmel_nand_probe(struct platform_device *pdev)
}
 
nand_chip->priv = host; /* link the private data structures */
-   mtd->priv = nand_chip;
mtd->dev.parent = >dev;
 
/* Set address of NAND IO lines */
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index 671d983..77d3b11 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -782,7 +782,6 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
 
/* initialise mtd info data struct */
mtd = nand_to_mtd(>chip);
-   mtd->priv   = chip;
mtd->dev.parent = >dev;
 
/* initialise the hardware */
diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c 
b/drivers/mtd/nand/brcmnand/brcmnand.c
index 20ebf00..a124147 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -1925,7 +1925,6 @@ static int brcmnand_init_cs(struct brcmnand_host *host)
 
nand_set_flash_node(chip, dn);
chip->priv = host;
-   mtd->priv = chip;
mtd->name = devm_kasprintf(>dev, GFP_KERNEL, "brcmnand.%d",
   host->cs);
mtd->owner = THIS_MODULE;
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 1d3a66c..096917a 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -611,7 +611,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 
mtd = nand_to_mtd(>nand);
mtd->dev.parent = >dev;
-   mtd->priv = >nand;
 
cafe->nand.priv = cafe;
cafe->pdev = pdev;
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c
index 84d027e..ca1f9b6 100644
--- a/drivers/mtd/nand/cmx270_nand.c
+++ b/drivers/mtd/nand/cmx270_nand.c
@@ -177,7 +177,6 @@ static int __init cmx270_init(void)
 
/* Link the private data with the MTD structure */
cmx270_nand_mtd->owner = THIS_MODULE;
-   cmx270_nand_mtd->priv = this;
 
/* insert callbacks */
this->IO_ADDR_R = cmx270_nand_io;
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
index ea51a9c..3a691d9 100644
--- a/drivers/mtd/nand/cs553x_nand.c
+++ b/drivers/mtd/nand/cs553x_nand.c
@@ -206,7 +206,

[PATCH 12/27] mtd: nand: embed an mtd_info structure into nand_chip

2015-11-16 Thread Boris Brezillon
Currently all NAND controller drivers are providing both the mtd_info and
nand_chip struct and then let the NAND subsystem to initialize a few
things before registering the mtd instance to the MTD layer.
Embed an mtd_info field into nand_chip to add some consistency to all NAND
controller drivers.
This change will also help factorizing boilerplate code copied in all NAND
drivers.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 include/linux/mtd/nand.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 056d165..c4e39ff 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -540,6 +540,7 @@ struct nand_buffers {
 
 /**
  * struct nand_chip - NAND Private Flash Chip Data
+ * @mtd:   MTD device registered to the MTD framework
  * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the
  * flash device
  * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the
@@ -640,6 +641,7 @@ struct nand_buffers {
  */
 
 struct nand_chip {
+   struct mtd_info mtd;
void __iomem *IO_ADDR_R;
void __iomem *IO_ADDR_W;
 
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/27] cris: nand: use the mtd instance embedded in struct nand_chip

2015-11-16 Thread Boris Brezillon
struct nand_chip now embeds an mtd device. Patch all drivers to make use
of this mtd instance instead of using the instance embedded in their
private struct or dynamically allocated.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
Most of those changes were generate with this coccinelle script:
http://code.bulix.org/5vxuih-89429
---
 arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 3 +--
 arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c 
b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index db953cf..ad78b97 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -36,7 +36,6 @@
 #define CE_BIT 12
 
 struct mtd_info_wrapper {
-   struct mtd_info info;
struct nand_chip chip;
 };
 
@@ -148,7 +147,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
 
/* Get pointer to private data */
this = >chip;
-   crisv32_mtd = >info;
+   crisv32_mtd = nand_to_mtd(>chip);
 
/* Link the private data with the MTD structure */
crisv32_mtd->priv = this;
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c 
b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index 22a6467..00a277b 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -31,7 +31,6 @@
 #define BY_BIT 7
 
 struct mtd_info_wrapper {
-   struct mtd_info info;
struct nand_chip chip;
 };
 
@@ -129,7 +128,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
 
/* Get pointer to private data */
this = >chip;
-   crisv32_mtd = >info;
+   crisv32_mtd = nand_to_mtd(>chip);
 
pa_oe.oe |= 1 << CE_BIT;
pa_oe.oe |= 1 << ALE_BIT;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/27] mtd: nand: simplify nand_dt_init() usage

2015-11-16 Thread Boris Brezillon
nand_dt_init() function requires 3 arguments where it actually needs one
(dn and mtd can both be retrieved from chip). Drop these parameters.

Testing for dn != NULL inside nand_dt_init() also helps simplifying the
caller code.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/mtd/nand/nand_base.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 71cc029..2f75eb1 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3937,11 +3937,17 @@ ident_done:
return type;
 }
 
-static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip,
-   struct device_node *dn)
+static int nand_dt_init(struct nand_chip *chip)
 {
+   struct device_node *dn = nand_get_flash_node(chip);
int ecc_mode, ecc_strength, ecc_step;
 
+   if (!dn)
+   return 0;
+
+   /* MTD can automatically handle DT partitions, etc. */
+   mtd_set_of_node(nand_to_mtd(chip), dn);
+
if (of_get_nand_bus_width(dn) == 16)
chip->options |= NAND_BUSWIDTH_16;
 
@@ -3989,14 +3995,9 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
struct nand_flash_dev *type;
int ret;
 
-   if (nand_get_flash_node(chip)) {
-   /* MTD can automatically handle DT partitions, etc. */
-   mtd_set_of_node(mtd, nand_get_flash_node(chip));
-
-   ret = nand_dt_init(mtd, chip, nand_get_flash_node(chip));
-   if (ret)
-   return ret;
-   }
+   ret = nand_dt_init(chip);
+   if (ret)
+   return ret;
 
/* Set the default functions */
nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16);
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/27] staging: mt29f_spinand: use the mtd instance embedded in struct nand_chip

2015-11-16 Thread Boris Brezillon
struct nand_chip now embeds an mtd device, use it instead of allocating
a new one.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c 
b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index 8924a96..8171b74 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -903,9 +903,7 @@ static int spinand_probe(struct spi_device *spi_nand)
chip->options   |= NAND_CACHEPRG;
chip->select_chip = spinand_select_chip;
 
-   mtd = devm_kzalloc(_nand->dev, sizeof(struct mtd_info), GFP_KERNEL);
-   if (!mtd)
-   return -ENOMEM;
+   mtd = nand_to_mtd(chip);
 
dev_set_drvdata(_nand->dev, mtd);
 
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 23/27] mtd: nand: kill the chip->flash_node field

2015-11-16 Thread Boris Brezillon
Now that the nand_chip struct directly embeds an mtd_info struct we can
get rid of the ->flash_node field and forward set/get_flash_node requests
to the MTD layer.

As a side effect, we no longer need the mtd_set_of_node() call done in
nand_dt_init().

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/mtd/nand/nand_base.c | 3 ---
 include/linux/mtd/nand.h | 7 ++-
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 2f75eb1..78e5123 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3945,9 +3945,6 @@ static int nand_dt_init(struct nand_chip *chip)
if (!dn)
return 0;
 
-   /* MTD can automatically handle DT partitions, etc. */
-   mtd_set_of_node(nand_to_mtd(chip), dn);
-
if (of_get_nand_bus_width(dn) == 16)
chip->options |= NAND_BUSWIDTH_16;
 
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 873646d..f12efe1 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -545,7 +545,6 @@ struct nand_buffers {
  * flash device
  * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the
  * flash device.
- * @flash_node:[BOARDSPECIFIC] device node describing this 
instance
  * @read_byte: [REPLACEABLE] read one byte from the chip
  * @read_word: [REPLACEABLE] read one word from the chip
  * @write_byte:[REPLACEABLE] write a single byte to the chip 
on the
@@ -645,8 +644,6 @@ struct nand_chip {
void __iomem *IO_ADDR_R;
void __iomem *IO_ADDR_W;
 
-   struct device_node *flash_node;
-
uint8_t (*read_byte)(struct mtd_info *mtd);
u16 (*read_word)(struct mtd_info *mtd);
void (*write_byte)(struct mtd_info *mtd, uint8_t byte);
@@ -724,12 +721,12 @@ struct nand_chip {
 static inline void nand_set_flash_node(struct nand_chip *chip,
   struct device_node *np)
 {
-   chip->flash_node = np;
+   mtd_set_of_node(>mtd, np);
 }
 
 static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
 {
-   return chip->flash_node;
+   return mtd_get_of_node(>mtd);
 }
 
 static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd)
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/27] mtd: nand: update mtd_to_nand()

2015-11-16 Thread Boris Brezillon
Now that all drivers are using the mtd instance embedded in the nand_chip
struct we can safely update the mtd_to_nand_chip() implementation to use
the container_of macro instead of returning the content of mtd->priv.
This will allow us to remove mtd->priv = chip assignments done in all
NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 include/linux/mtd/nand.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 8ec071e..873646d 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -734,7 +734,7 @@ static inline struct device_node 
*nand_get_flash_node(struct nand_chip *chip)
 
 static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd)
 {
-   return mtd->priv;
+   return container_of(mtd, struct nand_chip, mtd);
 }
 
 static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip)
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 25/27] ARM: make use of nand_set/get_controller_data() helpers

2015-11-16 Thread Boris Brezillon
New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 arch/arm/mach-ixp4xx/ixdp425-setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c 
b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index 333b0f9..508c2d7 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -77,7 +77,7 @@ static void
 ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
struct nand_chip *this = mtd_to_nand(mtd);
-   int offset = (int)this->priv;
+   int offset = (int)nand_get_controller_data(this);
 
if (ctrl & NAND_CTRL_CHANGE) {
if (ctrl & NAND_NCE) {
@@ -88,7 +88,7 @@ ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, 
unsigned int ctrl)
 
offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0;
offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0;
-   this->priv = (void *)offset;
+   nand_set_controller_data(this, (void *)offset);
}
 
if (cmd != NAND_CMD_NONE)
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/27] blackfin: nand: make use of mtd_to_nand() where appropriate

2015-11-16 Thread Boris Brezillon
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all blackfin specific implementations to use
this helper.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 arch/blackfin/mach-bf537/boards/stamp.c   | 2 +-
 arch/blackfin/mach-bf561/boards/acvilon.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/blackfin/mach-bf537/boards/stamp.c 
b/arch/blackfin/mach-bf537/boards/stamp.c
index 88a19fc..c181543 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -404,7 +404,7 @@ static struct mtd_partition bfin_plat_nand_partitions[] = {
 #define BFIN_NAND_PLAT_ALE 1
 static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned 
int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
 
if (cmd == NAND_CMD_NONE)
return;
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c 
b/arch/blackfin/mach-bf561/boards/acvilon.c
index 6ab9515..37f8f25 100644
--- a/arch/blackfin/mach-bf561/boards/acvilon.c
+++ b/arch/blackfin/mach-bf561/boards/acvilon.c
@@ -267,7 +267,7 @@ static struct mtd_partition bfin_plat_nand_partitions[] = {
 static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
unsigned int ctrl)
 {
-   struct nand_chip *this = mtd->priv;
+   struct nand_chip *this = mtd_to_nand(mtd);
 
if (cmd == NAND_CMD_NONE)
return;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/27] mtd: nand: fix drivers abusing mtd->priv

2015-11-16 Thread Boris Brezillon
The ->priv field of the mtd_info object attached to a nand_chip device
should point to the nand_chip device. The pxa and cafe drivers are
assigning this field their own private structure, which works fine as long
as the nand_chip field is the first one in the driver private struct but
seems a bit fragile.
Fix that by setting mtd->priv to point the nand_chip field and assigning
chip->priv to the private structure head.

Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
 drivers/mtd/nand/cafe_nand.c   | 34 ++
 drivers/mtd/nand/pxa3xx_nand.c | 30 +++---
 2 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 9de78d2..cce3ac4 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -101,7 +101,8 @@ static const char *part_probes[] = { "cmdlinepart", 
"RedBoot", NULL };
 
 static int cafe_device_ready(struct mtd_info *mtd)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x4000);
uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
 
@@ -117,7 +118,8 @@ static int cafe_device_ready(struct mtd_info *mtd)
 
 static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
 
if (usedma)
memcpy(cafe->dmabuf + cafe->datalen, buf, len);
@@ -132,7 +134,8 @@ static void cafe_write_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)
 
 static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
 
if (usedma)
memcpy(buf, cafe->dmabuf + cafe->datalen, len);
@@ -146,7 +149,8 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t 
*buf, int len)
 
 static uint8_t cafe_read_byte(struct mtd_info *mtd)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
uint8_t d;
 
cafe_read_buf(mtd, , 1);
@@ -158,7 +162,8 @@ static uint8_t cafe_read_byte(struct mtd_info *mtd)
 static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
  int column, int page_addr)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
int adrbytes = 0;
uint32_t ctl1;
uint32_t doneint = 0x8000;
@@ -313,7 +318,8 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, 
unsigned command,
 
 static void cafe_select_chip(struct mtd_info *mtd, int chipnr)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
 
cafe_dev_dbg(>pdev->dev, "select_chip %d\n", chipnr);
 
@@ -328,7 +334,8 @@ static void cafe_select_chip(struct mtd_info *mtd, int 
chipnr)
 static irqreturn_t cafe_nand_interrupt(int irq, void *id)
 {
struct mtd_info *mtd = id;
-   struct cafe_priv *cafe = mtd->priv;
+   struct nand_chip *chip = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
cafe_writel(cafe, irqs & ~0x9000, NAND_IRQ);
if (!irqs)
@@ -377,7 +384,7 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct 
nand_chip *chip,
 static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
   uint8_t *buf, int oob_required, int page)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
unsigned int max_bitflips = 0;
 
cafe_dev_dbg(>pdev->dev, "ECC result %08x SYN1,2 %08x\n",
@@ -519,7 +526,7 @@ static int cafe_nand_write_page_lowlevel(struct mtd_info 
*mtd,
  const uint8_t *buf, int oob_required,
  int page)
 {
-   struct cafe_priv *cafe = mtd->priv;
+   struct cafe_priv *cafe = chip->priv;
 
chip->write_buf(mtd, buf, mtd->writesize);
chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -604,7 +611,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe = (void *)([1]);
 
mtd->dev.parent = >dev;
-   mtd->priv = cafe;
+   mtd->priv = >nand;
+   cafe->nand.priv = cafe;
 
cafe->pdev = pdev;
cafe->mmio = pci_iomap(pdev, 0, 0);
@@ -792,7 +800,8 @@ static int cafe

  1   2   3   4   5   6   >