* Re: [PATCH v3 01/10] [media] Move mediabus format definition to a more standard place
From: Boris Brezillon @ 2014-11-07 16:09 UTC (permalink / raw)
To: Sakari Ailus
Cc: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-api-u79uwXL29TY76Z2rM5mHXA,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA, Guennadi Liakhovetski
In-Reply-To: <20141107152416.GC3136-S+BSfZ9RZZmRSg0ZkenSGLdO1Tsj/99ntUK59QYPAWc@public.gmane.org>
Hi Sakari,
On Fri, 7 Nov 2014 17:24:16 +0200
Sakari Ailus <sakari.ailus-X3B1VOXEql0@public.gmane.org> 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.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
> > Signed-off-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> > ---
> > 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 0000000..23b4090
[...]
> > +/* Vendor specific formats - next is 0x5002 */
> > +
> > +/* S5C73M3 sensor specific interleaved UYVY and JPEG */
> > +#define MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8 0x5001
> > +
> > +/* HSV - next is 0x6002 */
> > +#define MEDIA_BUS_FMT_AHSV8888_1X32 0x6001
> > +
> > +#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
^ permalink raw reply
* [PATCH v4 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel
From: Boris Brezillon @ 2014-11-07 16:27 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media, Sakari Ailus
Cc: devel, Boris Brezillon, linux-doc, linux-api, linux-kernel,
Guennadi Liakhovetski, linux-arm-kernel
In-Reply-To: <545CDB8D.4080406@xs4all.nl>
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.brezillon@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(AHSV8888_1X32),
};
+#endif /* __KERNEL__ */
/**
* struct v4l2_mbus_framefmt - frame format on the media bus
--
1.9.1
^ permalink raw reply related
* Re: [PATCH v5 2/7] vfs: Define new syscalls preadv2,pwritev2
From: Milosz Tanski @ 2014-11-07 16:28 UTC (permalink / raw)
To: Jeff Moyer
Cc: LKML, Christoph Hellwig, linux-fsdevel@vger.kernel.org,
linux-aio@kvack.org, Mel Gorman, Volker Lendecke, Tejun Heo,
Theodore Ts'o, Al Viro, Linux API, Michael Kerrisk,
linux-arch, linux-mm
In-Reply-To: <x49y4rn29oh.fsf@segfault.boston.devel.redhat.com>
On Thu, Nov 6, 2014 at 6:25 PM, Jeff Moyer <jmoyer@redhat.com> wrote:
> Milosz Tanski <milosz@adfin.com> writes:
>
>> New syscalls that take an flag argument. This change does not add any specific
>> flags.
>>
>> Signed-off-by: Milosz Tanski <milosz@adfin.com>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>> ---
>> fs/read_write.c | 176 ++++++++++++++++++++++++++++++--------
>> include/linux/compat.h | 6 ++
>> include/linux/syscalls.h | 6 ++
>> include/uapi/asm-generic/unistd.h | 6 +-
>> mm/filemap.c | 5 +-
>> 5 files changed, 158 insertions(+), 41 deletions(-)
>>
>> diff --git a/fs/read_write.c b/fs/read_write.c
>> index 94b2d34..907735c 100644
>> --- a/fs/read_write.c
>> +++ b/fs/read_write.c
>> @@ -866,6 +866,8 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec,
>> return -EBADF;
>> if (!(file->f_mode & FMODE_CAN_READ))
>> return -EINVAL;
>> + if (flags & ~0)
>> + return -EINVAL;
>>
>> return do_readv_writev(READ, file, vec, vlen, pos, flags);
>> }
>> @@ -879,21 +881,23 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
>> return -EBADF;
>> if (!(file->f_mode & FMODE_CAN_WRITE))
>> return -EINVAL;
>> + if (flags & ~0)
>> + return -EINVAL;
>>
>> return do_readv_writev(WRITE, file, vec, vlen, pos, flags);
>> }
>
> Hi, Milosz,
>
> You've checked for invalid flags for the normal system calls, but not
> for the compat variants. Can you add that in, please?
>
> Thanks!
> Jeff
That's a good catch Jeff I'll fix this and it'll be in the next
version of the patch series.
- M
--
Milosz Tanski
CTO
16 East 34th Street, 15th floor
New York, NY 10016
p: 646-253-9055
e: milosz@adfin.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* [PATCH v4 01/10] [media] Move mediabus format definition to a more standard place
From: Boris Brezillon @ 2014-11-07 16:28 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media, Sakari Ailus
Cc: devel, Boris Brezillon, linux-doc, linux-api, linux-kernel,
Guennadi Liakhovetski, linux-arm-kernel
In-Reply-To: <20141107152416.GC3136@valkosipuli.retiisi.org.uk>
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.liakhovetski@gmx.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Hans Verkuil <hans.verkuil@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 0000000..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.liakhovetski@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_FIXED 0x0001
+
+/* 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_BE 0x1005
+#define MEDIA_BUS_FMT_BGR565_2X8_LE 0x1006
+#define MEDIA_BUS_FMT_RGB565_2X8_BE 0x1007
+#define MEDIA_BUS_FMT_RGB565_2X8_LE 0x1008
+#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_ARGB8888_1X32 0x100d
+
+/* 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_2X8 0x2006
+#define MEDIA_BUS_FMT_VYUY8_2X8 0x2007
+#define MEDIA_BUS_FMT_YUYV8_2X8 0x2008
+#define MEDIA_BUS_FMT_YVYU8_2X8 0x2009
+#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 0x201b
+#define MEDIA_BUS_FMT_YUYV10_1X20 0x200d
+#define MEDIA_BUS_FMT_YVYU10_1X20 0x200e
+#define MEDIA_BUS_FMT_YUV10_1X30 0x2016
+#define MEDIA_BUS_FMT_AYUV8_1X32 0x2017
+#define MEDIA_BUS_FMT_UYVY12_2X12 0x201c
+#define MEDIA_BUS_FMT_VYUY12_2X12 0x201d
+#define MEDIA_BUS_FMT_YUYV12_2X12 0x201e
+#define MEDIA_BUS_FMT_YVYU12_2X12 0x201f
+#define MEDIA_BUS_FMT_UYVY12_1X24 0x2020
+#define MEDIA_BUS_FMT_VYUY12_1X24 0x2021
+#define MEDIA_BUS_FMT_YUYV12_1X24 0x2022
+#define MEDIA_BUS_FMT_YVYU12_1X24 0x2023
+
+/* Bayer - next is 0x3019 */
+#define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001
+#define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013
+#define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002
+#define MEDIA_BUS_FMT_SRGGB8_1X8 0x3014
+#define MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8 0x3015
+#define MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8 0x3016
+#define MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8 0x3017
+#define MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8 0x3018
+#define MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8 0x300b
+#define MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8 0x300c
+#define MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8 0x3009
+#define MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8 0x300d
+#define MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE 0x3003
+#define MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE 0x3004
+#define MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE 0x3005
+#define MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE 0x3006
+#define MEDIA_BUS_FMT_SBGGR10_1X10 0x3007
+#define MEDIA_BUS_FMT_SGBRG10_1X10 0x300e
+#define MEDIA_BUS_FMT_SGRBG10_1X10 0x300a
+#define MEDIA_BUS_FMT_SRGGB10_1X10 0x300f
+#define MEDIA_BUS_FMT_SBGGR12_1X12 0x3008
+#define MEDIA_BUS_FMT_SGBRG12_1X12 0x3010
+#define MEDIA_BUS_FMT_SGRBG12_1X12 0x3011
+#define MEDIA_BUS_FMT_SRGGB12_1X12 0x3012
+
+/* JPEG compressed formats - next is 0x4002 */
+#define MEDIA_BUS_FMT_JPEG_1X8 0x4001
+
+/* Vendor specific formats - next is 0x5002 */
+
+/* S5C73M3 sensor specific interleaved UYVY and JPEG */
+#define MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8 0x5001
+
+/* HSV - next is 0x6002 */
+#define MEDIA_BUS_FMT_AHSV8888_1X32 0x6001
+
+#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
diff --git a/include/uapi/linux/v4l2-mediabus.h b/include/uapi/linux/v4l2-mediabus.h
index 1445e85..d712df8 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -11,120 +11,96 @@
#ifndef __LINUX_V4L2_MEDIABUS_H
#define __LINUX_V4L2_MEDIABUS_H
+#include <linux/media-bus-format.h>
#include <linux/types.h>
#include <linux/videodev2.h>
-/*
- * 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
- /* RGB - next is 0x100e */
- V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
- V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
- V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
- V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE = 0x1004,
- V4L2_MBUS_FMT_BGR565_2X8_BE = 0x1005,
- V4L2_MBUS_FMT_BGR565_2X8_LE = 0x1006,
- V4L2_MBUS_FMT_RGB565_2X8_BE = 0x1007,
- V4L2_MBUS_FMT_RGB565_2X8_LE = 0x1008,
- V4L2_MBUS_FMT_RGB666_1X18 = 0x1009,
- V4L2_MBUS_FMT_RGB888_1X24 = 0x100a,
- V4L2_MBUS_FMT_RGB888_2X12_BE = 0x100b,
- V4L2_MBUS_FMT_RGB888_2X12_LE = 0x100c,
- V4L2_MBUS_FMT_ARGB8888_1X32 = 0x100d,
+enum v4l2_mbus_pixelcode {
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(FIXED),
- /* YUV (including grey) - next is 0x2024 */
- V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
- V4L2_MBUS_FMT_UV8_1X8 = 0x2015,
- V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
- V4L2_MBUS_FMT_VYUY8_1_5X8 = 0x2003,
- V4L2_MBUS_FMT_YUYV8_1_5X8 = 0x2004,
- V4L2_MBUS_FMT_YVYU8_1_5X8 = 0x2005,
- V4L2_MBUS_FMT_UYVY8_2X8 = 0x2006,
- V4L2_MBUS_FMT_VYUY8_2X8 = 0x2007,
- V4L2_MBUS_FMT_YUYV8_2X8 = 0x2008,
- V4L2_MBUS_FMT_YVYU8_2X8 = 0x2009,
- V4L2_MBUS_FMT_Y10_1X10 = 0x200a,
- V4L2_MBUS_FMT_UYVY10_2X10 = 0x2018,
- V4L2_MBUS_FMT_VYUY10_2X10 = 0x2019,
- V4L2_MBUS_FMT_YUYV10_2X10 = 0x200b,
- V4L2_MBUS_FMT_YVYU10_2X10 = 0x200c,
- V4L2_MBUS_FMT_Y12_1X12 = 0x2013,
- V4L2_MBUS_FMT_UYVY8_1X16 = 0x200f,
- V4L2_MBUS_FMT_VYUY8_1X16 = 0x2010,
- V4L2_MBUS_FMT_YUYV8_1X16 = 0x2011,
- V4L2_MBUS_FMT_YVYU8_1X16 = 0x2012,
- V4L2_MBUS_FMT_YDYUYDYV8_1X16 = 0x2014,
- V4L2_MBUS_FMT_UYVY10_1X20 = 0x201a,
- V4L2_MBUS_FMT_VYUY10_1X20 = 0x201b,
- V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
- V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
- V4L2_MBUS_FMT_YUV10_1X30 = 0x2016,
- V4L2_MBUS_FMT_AYUV8_1X32 = 0x2017,
- V4L2_MBUS_FMT_UYVY12_2X12 = 0x201c,
- V4L2_MBUS_FMT_VYUY12_2X12 = 0x201d,
- V4L2_MBUS_FMT_YUYV12_2X12 = 0x201e,
- V4L2_MBUS_FMT_YVYU12_2X12 = 0x201f,
- V4L2_MBUS_FMT_UYVY12_1X24 = 0x2020,
- V4L2_MBUS_FMT_VYUY12_1X24 = 0x2021,
- V4L2_MBUS_FMT_YUYV12_1X24 = 0x2022,
- V4L2_MBUS_FMT_YVYU12_1X24 = 0x2023,
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB444_2X8_PADHI_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB444_2X8_PADHI_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB555_2X8_PADHI_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB555_2X8_PADHI_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(BGR565_2X8_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(BGR565_2X8_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB565_2X8_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB565_2X8_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB666_1X18),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB888_1X24),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB888_2X12_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(RGB888_2X12_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(ARGB8888_1X32),
- /* Bayer - next is 0x3019 */
- V4L2_MBUS_FMT_SBGGR8_1X8 = 0x3001,
- V4L2_MBUS_FMT_SGBRG8_1X8 = 0x3013,
- V4L2_MBUS_FMT_SGRBG8_1X8 = 0x3002,
- V4L2_MBUS_FMT_SRGGB8_1X8 = 0x3014,
- V4L2_MBUS_FMT_SBGGR10_ALAW8_1X8 = 0x3015,
- V4L2_MBUS_FMT_SGBRG10_ALAW8_1X8 = 0x3016,
- V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8 = 0x3017,
- V4L2_MBUS_FMT_SRGGB10_ALAW8_1X8 = 0x3018,
- V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8 = 0x300b,
- V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8 = 0x300c,
- V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8 = 0x3009,
- V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8 = 0x300d,
- V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE = 0x3003,
- V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE = 0x3004,
- V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE = 0x3005,
- V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE = 0x3006,
- V4L2_MBUS_FMT_SBGGR10_1X10 = 0x3007,
- V4L2_MBUS_FMT_SGBRG10_1X10 = 0x300e,
- V4L2_MBUS_FMT_SGRBG10_1X10 = 0x300a,
- V4L2_MBUS_FMT_SRGGB10_1X10 = 0x300f,
- V4L2_MBUS_FMT_SBGGR12_1X12 = 0x3008,
- V4L2_MBUS_FMT_SGBRG12_1X12 = 0x3010,
- V4L2_MBUS_FMT_SGRBG12_1X12 = 0x3011,
- V4L2_MBUS_FMT_SRGGB12_1X12 = 0x3012,
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(Y8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UV8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY8_1_5X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY8_1_5X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV8_1_5X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU8_1_5X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY8_2X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY8_2X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV8_2X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU8_2X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(Y10_1X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY10_2X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY10_2X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV10_2X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU10_2X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(Y12_1X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY8_1X16),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY8_1X16),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV8_1X16),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU8_1X16),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YDYUYDYV8_1X16),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY10_1X20),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY10_1X20),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV10_1X20),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU10_1X20),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUV10_1X30),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(AYUV8_1X32),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY12_2X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY12_2X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV12_2X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU12_2X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(UYVY12_1X24),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(VYUY12_1X24),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YUYV12_1X24),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(YVYU12_1X24),
- /* JPEG compressed formats - next is 0x4002 */
- V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGBRG8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGRBG8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SRGGB8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_ALAW8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGBRG10_ALAW8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGRBG10_ALAW8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SRGGB10_ALAW8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_DPCM8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGBRG10_DPCM8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGRBG10_DPCM8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SRGGB10_DPCM8_1X8),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_2X8_PADHI_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_2X8_PADHI_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_2X8_PADLO_BE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_2X8_PADLO_LE),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR10_1X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGBRG10_1X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGRBG10_1X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SRGGB10_1X10),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SBGGR12_1X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGBRG12_1X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SGRBG12_1X12),
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(SRGGB12_1X12),
- /* Vendor specific formats - next is 0x5002 */
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(JPEG_1X8),
- /* S5C73M3 sensor specific interleaved UYVY and JPEG */
- V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8 = 0x5001,
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(S5C_UYVY_JPEG_1X8),
- /* HSV - next is 0x6002 */
- V4L2_MBUS_FMT_AHSV8888_1X32 = 0x6001,
+ V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV8888_1X32),
};
/**
--
1.9.1
^ permalink raw reply related
* [PATCHv7 0/3] syscalls,x86: Add execveat() system call
From: David Drysdale @ 2014-11-07 17:01 UTC (permalink / raw)
To: Eric W. Biederman, Andy Lutomirski, Alexander Viro, Meredydd Luff,
linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
Kees Cook, Arnd Bergmann, Rich Felker, Christoph Hellwig, x86,
linux-arch, linux-api, David Drysdale
This patch set adds execveat(2) for x86, and is derived from Meredydd
Luff's patch from Sept 2012 (https://lkml.org/lkml/2012/9/11/528).
The primary aim of adding an execveat syscall is to allow an
implementation of fexecve(3) that does not rely on the /proc
filesystem, at least for executables (rather than scripts). The
current glibc version of fexecve(3) is implemented via /proc, which
causes problems in sandboxed or otherwise restricted environments.
Given the desire for a /proc-free fexecve() implementation, HPA
suggested (https://lkml.org/lkml/2006/7/11/556) that an execveat(2)
syscall would be an appropriate generalization.
Also, having a new syscall means that it can take a flags argument
without back-compatibility concerns. The current implementation just
defines the AT_EMPTY_PATH and AT_SYMLINK_NOFOLLOW flags, but other
flags could be added in future -- for example, flags for new namespaces
(as suggested at https://lkml.org/lkml/2006/7/11/474).
Related history:
- https://lkml.org/lkml/2006/12/27/123 is an example of someone
realizing that fexecve() is likely to fail in a chroot environment.
- http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514043 covered
documenting the /proc requirement of fexecve(3) in its manpage, to
"prevent other people from wasting their time".
- https://bugzilla.redhat.com/show_bug.cgi?id=241609 described a
problem where a process that did setuid() could not fexecve()
because it no longer had access to /proc/self/fd; this has since
been fixed.
Changes since v6:
- Remove special case for O_PATH file descriptors [Andy Lutomirski]
- Use kasprintf rather than error-prone arithmetic [Kees Cook]
- Add test for long name [Kees Cook]
- Add test for non-executable O_PATH fd [Andy Lutomirski]
Changes since v5:
- Set new flag in bprm->interp_flags for O_CLOEXEC fds, so that binfmts
that invoke an interpreter fail the exec (as they will not be able
to access the invoked file). [Andy Lutomirski]
- Don't truncate long paths. [Andy Lutomirski]
- Commonize code to open the executed file. [Eric W. Biederman]
- Mark O_PATH file descriptors so they cannot be fexecve()ed.
- Make self-test more helpful, and add additional cases:
- file offset non-zero
- binary file without execute bit
- O_CLOEXEC fds
Changes since v4, suggested by Eric W. Biederman:
- Use empty filename with AT_EMPTY_PATH flag rather than NULL
pathname to request fexecve-like behaviour.
- Build pathname as "/dev/fd/<fd>/<filename>" (or "/dev/fd/<fd>")
rather than using d_path().
- Patch against v3.17 (bfe01a5ba249)
Changes since Meredydd's v3 patch:
- Added a selftest.
- Added a man page.
- Left open_exec() signature untouched to reduce patch impact
elsewhere (as suggested by Al Viro).
- Filled in bprm->filename with d_path() into a buffer, to avoid use
of potentially-ephemeral dentry->d_name.
- Patch against v3.14 (455c6fdbd21916).
David Drysdale (2):
syscalls,x86: implement execveat() system call
syscalls,x86: add selftest for execveat(2)
arch/x86/ia32/audit.c | 1 +
arch/x86/ia32/ia32entry.S | 1 +
arch/x86/kernel/audit_64.c | 1 +
arch/x86/kernel/entry_64.S | 28 +++
arch/x86/syscalls/syscall_32.tbl | 1 +
arch/x86/syscalls/syscall_64.tbl | 2 +
arch/x86/um/sys_call_table_64.c | 1 +
fs/binfmt_em86.c | 4 +
fs/binfmt_misc.c | 4 +
fs/binfmt_script.c | 10 +
fs/exec.c | 110 +++++++--
fs/namei.c | 2 +-
include/linux/binfmts.h | 4 +
include/linux/compat.h | 3 +
include/linux/fs.h | 1 +
include/linux/sched.h | 4 +
include/linux/syscalls.h | 4 +
include/uapi/asm-generic/unistd.h | 4 +-
kernel/sys_ni.c | 3 +
lib/audit.c | 3 +
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/exec/.gitignore | 9 +
tools/testing/selftests/exec/Makefile | 25 ++
tools/testing/selftests/exec/execveat.c | 397 ++++++++++++++++++++++++++++++++
24 files changed, 608 insertions(+), 15 deletions(-)
create mode 100644 tools/testing/selftests/exec/.gitignore
create mode 100644 tools/testing/selftests/exec/Makefile
create mode 100644 tools/testing/selftests/exec/execveat.c
--
2.1.0.rc2.206.gedb03e5
^ permalink raw reply
* [PATCHv7 1/3] syscalls,x86: implement execveat() system call
From: David Drysdale @ 2014-11-07 17:01 UTC (permalink / raw)
To: Eric W. Biederman, Andy Lutomirski, Alexander Viro, Meredydd Luff,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
Kees Cook, Arnd Bergmann, Rich Felker, Christoph Hellwig,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-arch-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, David Drysdale
In-Reply-To: <1415379664-31555-1-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Add a new execveat(2) system call. execveat() is to execve() as
openat() is to open(): it takes a file descriptor that refers to a
directory, and resolves the filename relative to that.
In addition, if the filename is empty and AT_EMPTY_PATH is specified,
execveat() executes the file to which the file descriptor refers. This
replicates the functionality of fexecve(), which is a system call in
other UNIXen, but in Linux glibc it depends on opening
"/proc/self/fd/<fd>" (and so relies on /proc being mounted).
The filename fed to the executed program as argv[0] (or the name of the
script fed to a script interpreter) will be of the form "/dev/fd/<fd>"
(for an empty filename) or "/dev/fd/<fd>/<filename>", effectively
reflecting how the executable was found. This does however mean that
execution of a script in a /proc-less environment won't work; also,
script execution via an O_CLOEXEC file descriptor fails (as the file
will not be accessible after exec).
Only x86-64, i386 and x32 ABIs are supported in this patch.
Based on patches by Meredydd Luff <meredydd-zPN50pYk8eUaUu29zAJCuw@public.gmane.org>
Signed-off-by: David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
arch/x86/ia32/audit.c | 1 +
arch/x86/ia32/ia32entry.S | 1 +
arch/x86/kernel/audit_64.c | 1 +
arch/x86/kernel/entry_64.S | 28 ++++++++++
arch/x86/syscalls/syscall_32.tbl | 1 +
arch/x86/syscalls/syscall_64.tbl | 2 +
arch/x86/um/sys_call_table_64.c | 1 +
fs/binfmt_em86.c | 4 ++
fs/binfmt_misc.c | 4 ++
fs/binfmt_script.c | 10 ++++
fs/exec.c | 110 +++++++++++++++++++++++++++++++++-----
fs/namei.c | 2 +-
include/linux/binfmts.h | 4 ++
include/linux/compat.h | 3 ++
include/linux/fs.h | 1 +
include/linux/sched.h | 4 ++
include/linux/syscalls.h | 4 ++
include/uapi/asm-generic/unistd.h | 4 +-
kernel/sys_ni.c | 3 ++
lib/audit.c | 3 ++
20 files changed, 176 insertions(+), 15 deletions(-)
diff --git a/arch/x86/ia32/audit.c b/arch/x86/ia32/audit.c
index 5d7b381da692..2eccc8932ae6 100644
--- a/arch/x86/ia32/audit.c
+++ b/arch/x86/ia32/audit.c
@@ -35,6 +35,7 @@ int ia32_classify_syscall(unsigned syscall)
case __NR_socketcall:
return 4;
case __NR_execve:
+ case __NR_execveat:
return 5;
default:
return 1;
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 4299eb05023c..2516c09743e0 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -464,6 +464,7 @@ GLOBAL(\label)
PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn
PTREGSCALL stub32_sigreturn, sys32_sigreturn
PTREGSCALL stub32_execve, compat_sys_execve
+ PTREGSCALL stub32_execveat, compat_sys_execveat
PTREGSCALL stub32_fork, sys_fork
PTREGSCALL stub32_vfork, sys_vfork
diff --git a/arch/x86/kernel/audit_64.c b/arch/x86/kernel/audit_64.c
index 06d3e5a14d9d..f3672508b249 100644
--- a/arch/x86/kernel/audit_64.c
+++ b/arch/x86/kernel/audit_64.c
@@ -50,6 +50,7 @@ int audit_classify_syscall(int abi, unsigned syscall)
case __NR_openat:
return 3;
case __NR_execve:
+ case __NR_execveat:
return 5;
default:
return 0;
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 2fac1343a90b..00c4526e6ffe 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -665,6 +665,20 @@ ENTRY(stub_execve)
CFI_ENDPROC
END(stub_execve)
+ENTRY(stub_execveat)
+ CFI_STARTPROC
+ addq $8, %rsp
+ PARTIAL_FRAME 0
+ SAVE_REST
+ FIXUP_TOP_OF_STACK %r11
+ call sys_execveat
+ RESTORE_TOP_OF_STACK %r11
+ movq %rax,RAX(%rsp)
+ RESTORE_REST
+ jmp int_ret_from_sys_call
+ CFI_ENDPROC
+END(stub_execveat)
+
/*
* sigreturn is special because it needs to restore all registers on return.
* This cannot be done with SYSRET, so use the IRET return path instead.
@@ -710,6 +724,20 @@ ENTRY(stub_x32_execve)
CFI_ENDPROC
END(stub_x32_execve)
+ENTRY(stub_x32_execveat)
+ CFI_STARTPROC
+ addq $8, %rsp
+ PARTIAL_FRAME 0
+ SAVE_REST
+ FIXUP_TOP_OF_STACK %r11
+ call compat_sys_execveat
+ RESTORE_TOP_OF_STACK %r11
+ movq %rax,RAX(%rsp)
+ RESTORE_REST
+ jmp int_ret_from_sys_call
+ CFI_ENDPROC
+END(stub_x32_execveat)
+
#endif
/*
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
index 028b78168d85..2633e3195455 100644
--- a/arch/x86/syscalls/syscall_32.tbl
+++ b/arch/x86/syscalls/syscall_32.tbl
@@ -363,3 +363,4 @@
354 i386 seccomp sys_seccomp
355 i386 getrandom sys_getrandom
356 i386 memfd_create sys_memfd_create
+357 i386 execveat sys_execveat stub32_execveat
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index 35dd922727b9..1af5badd159c 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -327,6 +327,7 @@
318 common getrandom sys_getrandom
319 common memfd_create sys_memfd_create
320 common kexec_file_load sys_kexec_file_load
+321 64 execveat stub_execveat
#
# x32-specific system call numbers start at 512 to avoid cache impact
@@ -365,3 +366,4 @@
542 x32 getsockopt compat_sys_getsockopt
543 x32 io_setup compat_sys_io_setup
544 x32 io_submit compat_sys_io_submit
+545 x32 execveat stub_x32_execveat
diff --git a/arch/x86/um/sys_call_table_64.c b/arch/x86/um/sys_call_table_64.c
index f2f0723070ca..20c3649d0691 100644
--- a/arch/x86/um/sys_call_table_64.c
+++ b/arch/x86/um/sys_call_table_64.c
@@ -31,6 +31,7 @@
#define stub_fork sys_fork
#define stub_vfork sys_vfork
#define stub_execve sys_execve
+#define stub_execveat sys_execveat
#define stub_rt_sigreturn sys_rt_sigreturn
#define __SYSCALL_COMMON(nr, sym, compat) __SYSCALL_64(nr, sym, compat)
diff --git a/fs/binfmt_em86.c b/fs/binfmt_em86.c
index f37b08cea1f7..490538536cb4 100644
--- a/fs/binfmt_em86.c
+++ b/fs/binfmt_em86.c
@@ -42,6 +42,10 @@ static int load_em86(struct linux_binprm *bprm)
return -ENOEXEC;
}
+ /* Need to be able to load the file after exec */
+ if (bprm->interp_flags & BINPRM_FLAGS_PATH_INACCESSIBLE)
+ return -ENOENT;
+
allow_write_access(bprm->file);
fput(bprm->file);
bprm->file = NULL;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index b60500300dd7..e659f5562356 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -127,6 +127,10 @@ static int load_misc_binary(struct linux_binprm *bprm)
if (!fmt)
goto _ret;
+ /* Need to be able to load the file after exec */
+ if (bprm->interp_flags & BINPRM_FLAGS_PATH_INACCESSIBLE)
+ return -ENOENT;
+
if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) {
retval = remove_arg_zero(bprm);
if (retval)
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index 5027a3e14922..afdf4e3cafc2 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -24,6 +24,16 @@ static int load_script(struct linux_binprm *bprm)
if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))
return -ENOEXEC;
+
+ /*
+ * If the script filename will be inaccessible after exec, typically
+ * because it is a "/dev/fd/<fd>/.." path against an O_CLOEXEC fd, give
+ * up now (on the assumption that the interpreter will want to load
+ * this file).
+ */
+ if (bprm->interp_flags & BINPRM_FLAGS_PATH_INACCESSIBLE)
+ return -ENOENT;
+
/*
* This section does the #! interpretation.
* Sorta complicated, but hopefully it will work. -TYT
diff --git a/fs/exec.c b/fs/exec.c
index a2b42a98c743..500363723b57 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -747,18 +747,25 @@ EXPORT_SYMBOL(setup_arg_pages);
#endif /* CONFIG_MMU */
-static struct file *do_open_exec(struct filename *name)
+static struct file *do_open_execat(int fd, struct filename *name, int flags)
{
struct file *file;
int err;
- static const struct open_flags open_exec_flags = {
+ struct open_flags open_exec_flags = {
.open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
.acc_mode = MAY_EXEC | MAY_OPEN,
.intent = LOOKUP_OPEN,
.lookup_flags = LOOKUP_FOLLOW,
};
- file = do_filp_open(AT_FDCWD, name, &open_exec_flags);
+ if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
+ return ERR_PTR(-EINVAL);
+ if (flags & AT_SYMLINK_NOFOLLOW)
+ open_exec_flags.lookup_flags &= ~LOOKUP_FOLLOW;
+ if (flags & AT_EMPTY_PATH)
+ open_exec_flags.lookup_flags |= LOOKUP_EMPTY;
+
+ file = do_filp_open(fd, name, &open_exec_flags);
if (IS_ERR(file))
goto out;
@@ -769,12 +776,13 @@ static struct file *do_open_exec(struct filename *name)
if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
goto exit;
- fsnotify_open(file);
-
err = deny_write_access(file);
if (err)
goto exit;
+ if (name->name[0] != '\0')
+ fsnotify_open(file);
+
out:
return file;
@@ -786,7 +794,7 @@ exit:
struct file *open_exec(const char *name)
{
struct filename tmp = { .name = name };
- return do_open_exec(&tmp);
+ return do_open_execat(AT_FDCWD, &tmp, 0);
}
EXPORT_SYMBOL(open_exec);
@@ -1422,10 +1430,12 @@ static int exec_binprm(struct linux_binprm *bprm)
/*
* sys_execve() executes a new program.
*/
-static int do_execve_common(struct filename *filename,
- struct user_arg_ptr argv,
- struct user_arg_ptr envp)
+static int do_execveat_common(int fd, struct filename *filename,
+ struct user_arg_ptr argv,
+ struct user_arg_ptr envp,
+ int flags)
{
+ char *pathbuf = NULL;
struct linux_binprm *bprm;
struct file *file;
struct files_struct *displaced;
@@ -1466,7 +1476,7 @@ static int do_execve_common(struct filename *filename,
check_unsafe_exec(bprm);
current->in_execve = 1;
- file = do_open_exec(filename);
+ file = do_open_execat(fd, filename, flags);
retval = PTR_ERR(file);
if (IS_ERR(file))
goto out_unmark;
@@ -1474,7 +1484,26 @@ static int do_execve_common(struct filename *filename,
sched_exec();
bprm->file = file;
- bprm->filename = bprm->interp = filename->name;
+ if (fd == AT_FDCWD || filename->name[0] == '/') {
+ bprm->filename = filename->name;
+ } else {
+ if (filename->name[0] == '\0')
+ pathbuf = kasprintf(GFP_TEMPORARY, "/dev/fd/%d", fd);
+ else
+ pathbuf = kasprintf(GFP_TEMPORARY, "/dev/fd/%d/%s",
+ fd, filename->name);
+ if (!pathbuf) {
+ retval = -ENOMEM;
+ goto out_unmark;
+ }
+ /* Record that a name derived from an O_CLOEXEC fd will be
+ * inaccessible after exec. Relies on having exclusive access to
+ * current->files (due to unshare_files above). */
+ if (close_on_exec(fd, current->files->fdt))
+ bprm->interp_flags |= BINPRM_FLAGS_PATH_INACCESSIBLE;
+ bprm->filename = pathbuf;
+ }
+ bprm->interp = bprm->filename;
retval = bprm_mm_init(bprm);
if (retval)
@@ -1532,6 +1561,7 @@ out_unmark:
out_free:
free_bprm(bprm);
+ kfree(pathbuf);
out_files:
if (displaced)
@@ -1547,7 +1577,18 @@ int do_execve(struct filename *filename,
{
struct user_arg_ptr argv = { .ptr.native = __argv };
struct user_arg_ptr envp = { .ptr.native = __envp };
- return do_execve_common(filename, argv, envp);
+ return do_execveat_common(AT_FDCWD, filename, argv, envp, 0);
+}
+
+int do_execveat(int fd, struct filename *filename,
+ const char __user *const __user *__argv,
+ const char __user *const __user *__envp,
+ int flags)
+{
+ struct user_arg_ptr argv = { .ptr.native = __argv };
+ struct user_arg_ptr envp = { .ptr.native = __envp };
+
+ return do_execveat_common(fd, filename, argv, envp, flags);
}
#ifdef CONFIG_COMPAT
@@ -1563,7 +1604,23 @@ static int compat_do_execve(struct filename *filename,
.is_compat = true,
.ptr.compat = __envp,
};
- return do_execve_common(filename, argv, envp);
+ return do_execveat_common(AT_FDCWD, filename, argv, envp, 0);
+}
+
+static int compat_do_execveat(int fd, struct filename *filename,
+ const compat_uptr_t __user *__argv,
+ const compat_uptr_t __user *__envp,
+ int flags)
+{
+ struct user_arg_ptr argv = {
+ .is_compat = true,
+ .ptr.compat = __argv,
+ };
+ struct user_arg_ptr envp = {
+ .is_compat = true,
+ .ptr.compat = __envp,
+ };
+ return do_execveat_common(fd, filename, argv, envp, flags);
}
#endif
@@ -1603,6 +1660,20 @@ SYSCALL_DEFINE3(execve,
{
return do_execve(getname(filename), argv, envp);
}
+
+SYSCALL_DEFINE5(execveat,
+ int, fd, const char __user *, filename,
+ const char __user *const __user *, argv,
+ const char __user *const __user *, envp,
+ int, flags)
+{
+ int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0;
+
+ return do_execveat(fd,
+ getname_flags(filename, lookup_flags, NULL),
+ argv, envp, flags);
+}
+
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
const compat_uptr_t __user *, argv,
@@ -1610,4 +1681,17 @@ COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
{
return compat_do_execve(getname(filename), argv, envp);
}
+
+COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
+ const char __user *, filename,
+ const compat_uptr_t __user *, argv,
+ const compat_uptr_t __user *, envp,
+ int, flags)
+{
+ int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0;
+
+ return compat_do_execveat(fd,
+ getname_flags(filename, lookup_flags, NULL),
+ argv, envp, flags);
+}
#endif
diff --git a/fs/namei.c b/fs/namei.c
index a7b05bf82d31..553c84d3e0cc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -130,7 +130,7 @@ void final_putname(struct filename *name)
#define EMBEDDED_NAME_MAX (PATH_MAX - sizeof(struct filename))
-static struct filename *
+struct filename *
getname_flags(const char __user *filename, int flags, int *empty)
{
struct filename *result, *err;
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index 61f29e5ea840..576e4639ca60 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -53,6 +53,10 @@ struct linux_binprm {
#define BINPRM_FLAGS_EXECFD_BIT 1
#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
+/* filename of the binary will be inaccessible after exec */
+#define BINPRM_FLAGS_PATH_INACCESSIBLE_BIT 2
+#define BINPRM_FLAGS_PATH_INACCESSIBLE (1 << BINPRM_FLAGS_PATH_INACCESSIBLE_BIT)
+
/* Function parameter for binfmt->coredump */
struct coredump_params {
const siginfo_t *siginfo;
diff --git a/include/linux/compat.h b/include/linux/compat.h
index e6494261eaff..7450ca2ac1fc 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -357,6 +357,9 @@ asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
const compat_uptr_t __user *envp);
+asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
+ const compat_uptr_t __user *argv,
+ const compat_uptr_t __user *envp, int flags);
asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
compat_ulong_t __user *outp, compat_ulong_t __user *exp,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 94187721ad41..e9818574d738 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2060,6 +2060,7 @@ extern struct file *file_open_root(struct dentry *, struct vfsmount *,
extern struct file * dentry_open(const struct path *, int, const struct cred *);
extern int filp_close(struct file *, fl_owner_t id);
+extern struct filename *getname_flags(const char __user *, int, int *);
extern struct filename *getname(const char __user *);
extern struct filename *getname_kernel(const char *);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index b867a4dab38a..33e056da7d33 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2430,6 +2430,10 @@ extern void do_group_exit(int);
extern int do_execve(struct filename *,
const char __user * const __user *,
const char __user * const __user *);
+extern int do_execveat(int, struct filename *,
+ const char __user * const __user *,
+ const char __user * const __user *,
+ int);
extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
struct task_struct *fork_idle(int);
extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 0f86d85a9ce4..df5422294deb 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -876,4 +876,8 @@ asmlinkage long sys_seccomp(unsigned int op, unsigned int flags,
asmlinkage long sys_getrandom(char __user *buf, size_t count,
unsigned int flags);
+asmlinkage long sys_execveat(int dfd, const char __user *filename,
+ const char __user *const __user *argv,
+ const char __user *const __user *envp, int flags);
+
#endif
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index 11d11bc5c78f..feef07d29663 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -705,9 +705,11 @@ __SYSCALL(__NR_seccomp, sys_seccomp)
__SYSCALL(__NR_getrandom, sys_getrandom)
#define __NR_memfd_create 279
__SYSCALL(__NR_memfd_create, sys_memfd_create)
+#define __NR_execveat 280
+__SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat)
#undef __NR_syscalls
-#define __NR_syscalls 280
+#define __NR_syscalls 281
/*
* All syscalls below here should go away really,
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 391d4ddb6f4b..efb06058ad3e 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -218,3 +218,6 @@ cond_syscall(sys_kcmp);
/* operate on Secure Computing state */
cond_syscall(sys_seccomp);
+
+/* execveat */
+cond_syscall(sys_execveat);
diff --git a/lib/audit.c b/lib/audit.c
index 1d726a22565b..b8fb5ee81e26 100644
--- a/lib/audit.c
+++ b/lib/audit.c
@@ -54,6 +54,9 @@ int audit_classify_syscall(int abi, unsigned syscall)
case __NR_socketcall:
return 4;
#endif
+#ifdef __NR_execveat
+ case __NR_execveat:
+#endif
case __NR_execve:
return 5;
default:
--
2.1.0.rc2.206.gedb03e5
^ permalink raw reply related
* [PATCHv7 2/3] syscalls,x86: add selftest for execveat(2)
From: David Drysdale @ 2014-11-07 17:01 UTC (permalink / raw)
To: Eric W. Biederman, Andy Lutomirski, Alexander Viro, Meredydd Luff,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
Kees Cook, Arnd Bergmann, Rich Felker, Christoph Hellwig,
x86-DgEjT+Ai2ygdnm+yROfE0A, linux-arch-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, David Drysdale
In-Reply-To: <1415379664-31555-1-git-send-email-drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Signed-off-by: David Drysdale <drysdale-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/exec/.gitignore | 9 +
tools/testing/selftests/exec/Makefile | 25 ++
tools/testing/selftests/exec/execveat.c | 397 ++++++++++++++++++++++++++++++++
4 files changed, 432 insertions(+)
create mode 100644 tools/testing/selftests/exec/.gitignore
create mode 100644 tools/testing/selftests/exec/Makefile
create mode 100644 tools/testing/selftests/exec/execveat.c
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 36ff2e4c7b6f..210cf68b3511 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -14,6 +14,7 @@ TARGETS += powerpc
TARGETS += user
TARGETS += sysctl
TARGETS += firmware
+TARGETS += exec
TARGETS_HOTPLUG = cpu-hotplug
TARGETS_HOTPLUG += memory-hotplug
diff --git a/tools/testing/selftests/exec/.gitignore b/tools/testing/selftests/exec/.gitignore
new file mode 100644
index 000000000000..64073e050c6a
--- /dev/null
+++ b/tools/testing/selftests/exec/.gitignore
@@ -0,0 +1,9 @@
+subdir*
+script*
+execveat
+execveat.symlink
+execveat.moved
+execveat.path.ephemeral
+execveat.ephemeral
+execveat.denatured
+xxxxxxxx*
\ No newline at end of file
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
new file mode 100644
index 000000000000..66dfc2ce1788
--- /dev/null
+++ b/tools/testing/selftests/exec/Makefile
@@ -0,0 +1,25 @@
+CC = $(CROSS_COMPILE)gcc
+CFLAGS = -Wall
+BINARIES = execveat
+DEPS = execveat.symlink execveat.denatured script subdir
+all: $(BINARIES) $(DEPS)
+
+subdir:
+ mkdir -p $@
+script:
+ echo '#!/bin/sh' > $@
+ echo 'exit $$*' >> $@
+ chmod +x $@
+execveat.symlink: execveat
+ ln -s -f $< $@
+execveat.denatured: execveat
+ cp $< $@
+ chmod -x $@
+%: %.c
+ $(CC) $(CFLAGS) -o $@ $^
+
+run_tests: all
+ ./execveat
+
+clean:
+ rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c
new file mode 100644
index 000000000000..33a5c06d95ca
--- /dev/null
+++ b/tools/testing/selftests/exec/execveat.c
@@ -0,0 +1,397 @@
+/*
+ * Copyright (c) 2014 Google, Inc.
+ *
+ * Licensed under the terms of the GNU GPL License version 2
+ *
+ * Selftests for execveat(2).
+ */
+
+#define _GNU_SOURCE /* to get O_PATH, AT_EMPTY_PATH */
+#include <sys/sendfile.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static char longpath[2 * PATH_MAX] = "";
+static char *envp[] = { "IN_TEST=yes", NULL, NULL };
+static char *argv[] = { "execveat", "99", NULL };
+
+static int execveat_(int fd, const char *path, char **argv, char **envp,
+ int flags)
+{
+#ifdef __NR_execveat
+ return syscall(__NR_execveat, fd, path, argv, envp, flags);
+#else
+ errno = -ENOSYS;
+ return -1;
+#endif
+}
+
+#define check_execveat_fail(fd, path, flags, errno) \
+ _check_execveat_fail(fd, path, flags, errno, #errno)
+static int _check_execveat_fail(int fd, const char *path, int flags,
+ int expected_errno, const char *errno_str)
+{
+ int rc;
+
+ errno = 0;
+ printf("Check failure of execveat(%d, '%s', %d) with %s... ",
+ fd, path?:"(null)", flags, errno_str);
+ rc = execveat_(fd, path, argv, envp, flags);
+
+ if (rc > 0) {
+ printf("[FAIL] (unexpected success from execveat(2))\n");
+ return 1;
+ }
+ if (errno != expected_errno) {
+ printf("[FAIL] (expected errno %d (%s) not %d (%s)\n",
+ expected_errno, strerror(expected_errno),
+ errno, strerror(errno));
+ return 1;
+ }
+ printf("[OK]\n");
+ return 0;
+}
+
+static int check_execveat_invoked_rc(int fd, const char *path, int flags,
+ int expected_rc)
+{
+ int status;
+ int rc;
+ pid_t child;
+ int pathlen = path ? strlen(path) : 0;
+
+ if (pathlen > 40)
+ printf("Check success of execveat(%d, '%.20s...%s', %d)... ",
+ fd, path, (path + pathlen - 20), flags);
+ else
+ printf("Check success of execveat(%d, '%s', %d)... ",
+ fd, path?:"(null)", flags);
+ child = fork();
+ if (child < 0) {
+ printf("[FAIL] (fork() failed)\n");
+ return 1;
+ }
+ if (child == 0) {
+ /* Child: do execveat(). */
+ rc = execveat_(fd, path, argv, envp, flags);
+ printf("[FAIL]: execveat() failed, rc=%d errno=%d (%s)\n",
+ rc, errno, strerror(errno));
+ exit(1); /* should not reach here */
+ }
+ /* Parent: wait for & check child's exit status. */
+ rc = waitpid(child, &status, 0);
+ if (rc != child) {
+ printf("[FAIL] (waitpid(%d,...) returned %d)\n", child, rc);
+ return 1;
+ }
+ if (!WIFEXITED(status)) {
+ printf("[FAIL] (child %d did not exit cleanly, status=%08x)\n",
+ child, status);
+ return 1;
+ }
+ if (WEXITSTATUS(status) != expected_rc) {
+ printf("[FAIL] (child %d exited with %d not %d)\n",
+ child, WEXITSTATUS(status), expected_rc);
+ return 1;
+ }
+ printf("[OK]\n");
+ return 0;
+}
+
+static int check_execveat(int fd, const char *path, int flags)
+{
+ return check_execveat_invoked_rc(fd, path, flags, 99);
+}
+
+static char *concat(const char *left, const char *right)
+{
+ char *result = malloc(strlen(left) + strlen(right) + 1);
+
+ strcpy(result, left);
+ strcat(result, right);
+ return result;
+}
+
+static int open_or_die(const char *filename, int flags)
+{
+ int fd = open(filename, flags);
+
+ if (fd < 0) {
+ printf("Failed to open '%s'; "
+ "check prerequisites are available\n", filename);
+ exit(1);
+ }
+ return fd;
+}
+
+static void exe_cp(const char *src, const char *dest)
+{
+ int in_fd = open_or_die(src, O_RDONLY);
+ int out_fd = open(dest, O_RDWR|O_CREAT|O_TRUNC, 0755);
+ struct stat info;
+
+ fstat(in_fd, &info);
+ sendfile(out_fd, in_fd, NULL, info.st_size);
+ close(in_fd);
+ close(out_fd);
+}
+
+#define XX_DIR_LEN 200
+static int check_execveat_pathmax(int dot_dfd, const char *src, int is_script)
+{
+ int fail = 0;
+ int ii, count, len;
+ char longname[XX_DIR_LEN + 1];
+ int fd;
+
+ if (*longpath == '\0') {
+ /* Create a filename close to PATH_MAX in length */
+ memset(longname, 'x', XX_DIR_LEN - 1);
+ longname[XX_DIR_LEN - 1] = '/';
+ longname[XX_DIR_LEN] = '\0';
+ count = (PATH_MAX - 3) / XX_DIR_LEN;
+ for (ii = 0; ii < count; ii++) {
+ strcat(longpath, longname);
+ mkdir(longpath, 0755);
+ }
+ len = (PATH_MAX - 3) - (count * XX_DIR_LEN);
+ if (len <= 0)
+ len = 1;
+ memset(longname, 'y', len);
+ longname[len] = '\0';
+ strcat(longpath, longname);
+ }
+ exe_cp(src, longpath);
+
+ /*
+ * Execute as a pre-opened file descriptor, which works whether this is
+ * a script or not (because the interpreter sees a filename like
+ * "/dev/fd/20").
+ */
+ fd = open(longpath, O_RDONLY);
+ if (fd > 0) {
+ printf("Invoke copy of '%s' via filename of length %lu:\n",
+ src, strlen(longpath));
+ fail += check_execveat(fd, "", AT_EMPTY_PATH);
+ } else {
+ printf("Failed to open length %lu filename, errno=%d (%s)\n",
+ strlen(longpath), errno, strerror(errno));
+ fail++;
+ }
+
+ /*
+ * Execute as a long pathname relative to ".". If this is a script,
+ * the interpreter will launch but fail to open the script because its
+ * name ("/dev/fd/5/xxx....") is bigger than PATH_MAX.
+ */
+ if (is_script)
+ fail += check_execveat_invoked_rc(dot_dfd, longpath, 0, 127);
+ else
+ fail += check_execveat(dot_dfd, longpath, 0);
+
+ return fail;
+}
+
+static int run_tests(void)
+{
+ int fail = 0;
+ char *fullname = realpath("execveat", NULL);
+ char *fullname_script = realpath("script", NULL);
+ char *fullname_symlink = concat(fullname, ".symlink");
+ int subdir_dfd = open_or_die("subdir", O_DIRECTORY|O_RDONLY);
+ int subdir_dfd_ephemeral = open_or_die("subdir.ephemeral",
+ O_DIRECTORY|O_RDONLY);
+ int dot_dfd = open_or_die(".", O_DIRECTORY|O_RDONLY);
+ int dot_dfd_path = open_or_die(".", O_DIRECTORY|O_RDONLY|O_PATH);
+ int dot_dfd_cloexec = open_or_die(".", O_DIRECTORY|O_RDONLY|O_CLOEXEC);
+ int fd = open_or_die("execveat", O_RDONLY);
+ int fd_path = open_or_die("execveat", O_RDONLY|O_PATH);
+ int fd_symlink = open_or_die("execveat.symlink", O_RDONLY);
+ int fd_denatured = open_or_die("execveat.denatured", O_RDONLY);
+ int fd_denatured_path = open_or_die("execveat.denatured",
+ O_RDONLY|O_PATH);
+ int fd_script = open_or_die("script", O_RDONLY);
+ int fd_ephemeral = open_or_die("execveat.ephemeral", O_RDONLY);
+ int fd_ephemeral_path = open_or_die("execveat.path.ephemeral",
+ O_RDONLY|O_PATH);
+ int fd_script_ephemeral = open_or_die("script.ephemeral", O_RDONLY);
+ int fd_cloexec = open_or_die("execveat", O_RDONLY|O_CLOEXEC);
+ int fd_script_cloexec = open_or_die("script", O_RDONLY|O_CLOEXEC);
+
+ /* Change file position to confirm it doesn't affect anything */
+ lseek(fd, 10, SEEK_SET);
+
+ /* Normal executable file: */
+ /* dfd + path */
+ fail += check_execveat(subdir_dfd, "../execveat", 0);
+ fail += check_execveat(dot_dfd, "execveat", 0);
+ fail += check_execveat(dot_dfd_path, "execveat", 0);
+ /* absolute path */
+ fail += check_execveat(AT_FDCWD, fullname, 0);
+ /* absolute path with nonsense dfd */
+ fail += check_execveat(99, fullname, 0);
+ /* fd + no path */
+ fail += check_execveat(fd, "", AT_EMPTY_PATH);
+ /* O_CLOEXEC fd + no path */
+ fail += check_execveat(fd_cloexec, "", AT_EMPTY_PATH);
+ /* O_PATH fd */
+ fail += check_execveat(fd_path, "", AT_EMPTY_PATH);
+
+ /* Mess with executable file that's already open: */
+ /* fd + no path to a file that's been renamed */
+ rename("execveat.ephemeral", "execveat.moved");
+ fail += check_execveat(fd_ephemeral, "", AT_EMPTY_PATH);
+ /* fd + no path to a file that's been deleted */
+ unlink("execveat.moved"); /* remove the file now fd open */
+ fail += check_execveat(fd_ephemeral, "", AT_EMPTY_PATH);
+
+ /* Mess with executable file that's already open with O_PATH */
+ /* fd + no path to a file that's been deleted */
+ unlink("execveat.path.ephemeral");
+ fail += check_execveat(fd_ephemeral_path, "", AT_EMPTY_PATH);
+
+ /* Invalid argument failures */
+ fail += check_execveat_fail(fd, "", 0, ENOENT);
+ fail += check_execveat_fail(fd, NULL, AT_EMPTY_PATH, EFAULT);
+
+ /* Symlink to executable file: */
+ /* dfd + path */
+ fail += check_execveat(dot_dfd, "execveat.symlink", 0);
+ fail += check_execveat(dot_dfd_path, "execveat.symlink", 0);
+ /* absolute path */
+ fail += check_execveat(AT_FDCWD, fullname_symlink, 0);
+ /* fd + no path, even with AT_SYMLINK_NOFOLLOW (already followed) */
+ fail += check_execveat(fd_symlink, "", AT_EMPTY_PATH);
+ fail += check_execveat(fd_symlink, "",
+ AT_EMPTY_PATH|AT_SYMLINK_NOFOLLOW);
+
+ /* Symlink fails when AT_SYMLINK_NOFOLLOW set: */
+ /* dfd + path */
+ fail += check_execveat_fail(dot_dfd, "execveat.symlink",
+ AT_SYMLINK_NOFOLLOW, ELOOP);
+ fail += check_execveat_fail(dot_dfd_path, "execveat.symlink",
+ AT_SYMLINK_NOFOLLOW, ELOOP);
+ /* absolute path */
+ fail += check_execveat_fail(AT_FDCWD, fullname_symlink,
+ AT_SYMLINK_NOFOLLOW, ELOOP);
+
+ /* Shell script wrapping executable file: */
+ /* dfd + path */
+ fail += check_execveat(subdir_dfd, "../script", 0);
+ fail += check_execveat(dot_dfd, "script", 0);
+ fail += check_execveat(dot_dfd_path, "script", 0);
+ /* absolute path */
+ fail += check_execveat(AT_FDCWD, fullname_script, 0);
+ /* fd + no path */
+ fail += check_execveat(fd_script, "", AT_EMPTY_PATH);
+ fail += check_execveat(fd_script, "",
+ AT_EMPTY_PATH|AT_SYMLINK_NOFOLLOW);
+ /* O_CLOEXEC fd fails for a script (as script file inaccessible) */
+ fail += check_execveat_fail(fd_script_cloexec, "", AT_EMPTY_PATH,
+ ENOENT);
+ fail += check_execveat_fail(dot_dfd_cloexec, "script", 0, ENOENT);
+
+ /* Mess with script file that's already open: */
+ /* fd + no path to a file that's been renamed */
+ rename("script.ephemeral", "script.moved");
+ fail += check_execveat(fd_script_ephemeral, "", AT_EMPTY_PATH);
+ /* fd + no path to a file that's been deleted */
+ unlink("script.moved"); /* remove the file while fd open */
+ fail += check_execveat(fd_script_ephemeral, "", AT_EMPTY_PATH);
+
+ /* Rename a subdirectory in the path: */
+ rename("subdir.ephemeral", "subdir.moved");
+ fail += check_execveat(subdir_dfd_ephemeral, "../script", 0);
+ fail += check_execveat(subdir_dfd_ephemeral, "script", 0);
+ /* Remove the subdir and its contents */
+ unlink("subdir.moved/script");
+ unlink("subdir.moved");
+ /* Shell loads via deleted subdir OK because name starts with .. */
+ fail += check_execveat(subdir_dfd_ephemeral, "../script", 0);
+ fail += check_execveat_fail(subdir_dfd_ephemeral, "script", 0, ENOENT);
+
+ /* Flag values other than AT_SYMLINK_NOFOLLOW => EINVAL */
+ fail += check_execveat_fail(dot_dfd, "execveat", 0xFFFF, EINVAL);
+ /* Invalid path => ENOENT */
+ fail += check_execveat_fail(dot_dfd, "no-such-file", 0, ENOENT);
+ fail += check_execveat_fail(dot_dfd_path, "no-such-file", 0, ENOENT);
+ fail += check_execveat_fail(AT_FDCWD, "no-such-file", 0, ENOENT);
+ /* Attempt to execute directory => EACCES */
+ fail += check_execveat_fail(dot_dfd, "", AT_EMPTY_PATH, EACCES);
+ /* Attempt to execute non-executable => EACCES */
+ fail += check_execveat_fail(dot_dfd, "Makefile", 0, EACCES);
+ fail += check_execveat_fail(fd_denatured, "", AT_EMPTY_PATH, EACCES);
+ fail += check_execveat_fail(fd_denatured_path, "", AT_EMPTY_PATH,
+ EACCES);
+ /* Attempt to execute nonsense FD => EBADF */
+ fail += check_execveat_fail(99, "", AT_EMPTY_PATH, EBADF);
+ fail += check_execveat_fail(99, "execveat", 0, EBADF);
+ /* Attempt to execute relative to non-directory => ENOTDIR */
+ fail += check_execveat_fail(fd, "execveat", 0, ENOTDIR);
+
+ fail += check_execveat_pathmax(dot_dfd, "execveat", 0);
+ fail += check_execveat_pathmax(dot_dfd, "script", 1);
+ return fail;
+}
+
+static void prerequisites(void)
+{
+ int fd;
+ const char *script = "#!/bin/sh\nexit $*\n";
+
+ /* Create ephemeral copies of files */
+ exe_cp("execveat", "execveat.ephemeral");
+ exe_cp("execveat", "execveat.path.ephemeral");
+ exe_cp("script", "script.ephemeral");
+ mkdir("subdir.ephemeral", 0755);
+
+ fd = open("subdir.ephemeral/script", O_RDWR|O_CREAT|O_TRUNC, 0755);
+ write(fd, script, strlen(script));
+ close(fd);
+}
+
+int main(int argc, char **argv)
+{
+ int ii;
+ int rc;
+ const char *verbose = getenv("VERBOSE");
+
+ if (argc >= 2) {
+ /* If we are invoked with an argument, don't run tests. */
+ const char *in_test = getenv("IN_TEST");
+
+ if (verbose) {
+ printf(" invoked with:");
+ for (ii = 0; ii < argc; ii++)
+ printf(" [%d]='%s'", ii, argv[ii]);
+ printf("\n");
+ }
+
+ /* Check expected environment transferred. */
+ if (!in_test || strcmp(in_test, "yes") != 0) {
+ printf("[FAIL] (no IN_TEST=yes in env)\n");
+ return 1;
+ }
+
+ /* Use the final argument as an exit code. */
+ rc = atoi(argv[argc - 1]);
+ fflush(stdout);
+ } else {
+ prerequisites();
+ if (verbose)
+ envp[1] = "VERBOSE=1";
+ rc = run_tests();
+ if (rc > 0)
+ printf("%d tests failed\n", rc);
+ }
+ return rc;
+}
--
2.1.0.rc2.206.gedb03e5
^ permalink raw reply related
* [PATCHv7 man-pages 3/3] execveat.2: initial man page for execveat(2)
From: David Drysdale @ 2014-11-07 17:01 UTC (permalink / raw)
To: Eric W. Biederman, Andy Lutomirski, Alexander Viro, Meredydd Luff,
linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
Kees Cook, Arnd Bergmann, Rich Felker, Christoph Hellwig, x86,
linux-arch, linux-api, David Drysdale
In-Reply-To: <1415379664-31555-1-git-send-email-drysdale@google.com>
Signed-off-by: David Drysdale <drysdale@google.com>
---
man2/execveat.2 | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 153 insertions(+)
create mode 100644 man2/execveat.2
diff --git a/man2/execveat.2 b/man2/execveat.2
new file mode 100644
index 000000000000..937d79e4c4f0
--- /dev/null
+++ b/man2/execveat.2
@@ -0,0 +1,153 @@
+.\" Copyright (c) 2014 Google, Inc.
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date. The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein. The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.TH EXECVEAT 2 2014-04-02 "Linux" "Linux Programmer's Manual"
+.SH NAME
+execveat \- execute program relative to a directory file descriptor
+.SH SYNOPSIS
+.B #include <unistd.h>
+.sp
+.BI "int execveat(int " fd ", const char *" pathname ","
+.br
+.BI " char *const " argv "[], char *const " envp "[],"
+.br
+.BI " int " flags);
+.SH DESCRIPTION
+The
+.BR execveat ()
+system call executes the program pointed to by the combination of \fIfd\fP and \fIpathname\fP.
+The
+.BR execveat ()
+system call operates in exactly the same way as
+.BR execve (2),
+except for the differences described in this manual page.
+
+If the pathname given in
+.I pathname
+is relative, then it is interpreted relative to the directory
+referred to by the file descriptor
+.I fd
+(rather than relative to the current working directory of
+the calling process, as is done by
+.BR execve (2)
+for a relative pathname).
+
+If
+.I pathname
+is relative and
+.I fd
+is the special value
+.BR AT_FDCWD ,
+then
+.I pathname
+is interpreted relative to the current working
+directory of the calling process (like
+.BR execve (2)).
+
+If
+.I pathname
+is absolute, then
+.I fd
+is ignored.
+
+If
+.I pathname
+is an empty string and the
+.BR AT_EMPTY_PATH
+flag is specified, then the file descriptor
+.I fd
+specifies the file to be executed.
+
+.I flags
+can either be 0, or include the following flags:
+.TP
+.BR AT_EMPTY_PATH
+If
+.I pathname
+is an empty string, operate on the file referred to by
+.IR fd
+(which may have been obtained using the
+.BR open (2)
+.B O_PATH
+flag).
+.TP
+.B AT_SYMLINK_NOFOLLOW
+If the file identified by
+.I fd
+and a non-NULL
+.I pathname
+is a symbolic link, then the call fails with the error
+.BR EINVAL .
+.SH "RETURN VALUE"
+On success,
+.BR execveat ()
+does not return. On error \-1 is returned, and
+.I errno
+is set appropriately.
+.SH ERRORS
+The same errors that occur for
+.BR execve (2)
+can also occur for
+.BR execveat ().
+The following additional errors can occur for
+.BR execveat ():
+.TP
+.B EBADF
+.I fd
+is not a valid file descriptor.
+.TP
+.B ENOENT
+The program identified by \fIfd\fP and \fIpathname\fP requires the
+use of an interpreter program (such as a script starting with
+"#!") but the file descriptor
+.I fd
+was opened with the
+.B O_CLOEXEC
+flag and so the program file is inaccessible to the launched interpreter.
+.TP
+.B EINVAL
+Invalid flag specified in
+.IR flags .
+.TP
+.B ENOTDIR
+.I pathname
+is relative and
+.I fd
+is a file descriptor referring to a file other than a directory.
+.SH VERSIONS
+.BR execveat ()
+was added to Linux in kernel 3.???.
+.SH NOTES
+In addition to the reasons explained in
+.BR openat (2),
+the
+.BR execveat ()
+system call is also needed to allow
+.BR fexecve (3)
+to be implemented on systems that do not have the
+.I /proc
+filesystem mounted.
+.SH SEE ALSO
+.BR execve (2),
+.BR fexecve (3)
--
2.1.0.rc2.206.gedb03e5
^ permalink raw reply related
* Re: [RFC PATCH 0/5] kdbus: add support for lsm
From: Greg KH @ 2014-11-07 18:01 UTC (permalink / raw)
To: Karol Lewandowski
Cc: pmoore, jkosina, linux-api, inux-kernel, john.stultz, arnd, tj,
desrt, simon.mcvittie, daniel, dh.herrmann, casey.schaufler,
marcel, tixxdz, javier.martinez, alban.crequy,
linux-security-module, lmctlx, r.krypa
In-Reply-To: <1414773397-26490-1-git-send-email-k.lewandowsk@samsung.com>
On Fri, Oct 31, 2014 at 05:36:32PM +0100, Karol Lewandowski wrote:
> This is set of EXPERIMENTAL patches adding lsm support to kdbus.
> (Rebased on top of v3.17.)
>
> >From least to most invasive:
>
> - (1) kdbus: extend structures with security pointer for lsm
>
> Trivial. Applicable as-is.
>
> - (2) security: export security_file_receive for modules
> (3) kdbus: check if lsm permits installing received fds
>
> fd_install doesn't seem to consult LSM, these patches
> ensure that receiving process has the right to sent fds.
>
> Compile-tested only.
>
> - (4) security: introduce lsm hooks for kdbus
> (5) kdbus: make use of new lsm hooks
>
> Set of proof-of-concept hooks discussed previously with Paul Moore.
>
> kdbus integration patch (5) for review, but unlikely for integration
> at this stage.
>
> Likewise, compile-tested only.
>
>
> Karol Lewandowski (5):
> kdbus: extend structures with security pointer for lsm
> security: export security_file_receive for modules
> kdbus: check if lsm permits installing received fds
> security: introduce lsm hooks for kdbus
> kdbus: make use of new lsm hooks
These looks reasonable to me, thanks for sending them. They will need
to be refreshed again after this next round of changes, but it shouldn't
be that hard to do so.
thanks,
greg k-h
^ permalink raw reply
* Re: [fuse-devel] [PATCH v5 7/7] add a flag for per-operation O_DSYNC semantics
From: Milosz Tanski @ 2014-11-07 19:58 UTC (permalink / raw)
To: Roger Willcocks
Cc: Anton Altaparmakov, Anand Avati, linux-arch, linux-aio@kvack.org,
linux-nfs, Volker Lendecke, Theodore Ts'o, Mel Gorman,
fuse-devel@lists.sourceforge.net, Linux API,
Linux Kernel Mailing List, Michael Kerrisk, Christoph Hellwig,
linux-mm, Jeff Moyer, Al Viro, Tejun Heo,
linux-fsdevel@vger.kernel.org, ceph-devel, Christoph Hellwig,
ocfs2-devel
In-Reply-To: <1415370078.11083.511.camel@montana.filmlight.ltd.uk>
On Fri, Nov 7, 2014 at 9:21 AM, Roger Willcocks <roger@filmlight.ltd.uk> wrote:
>
> On Fri, 2014-11-07 at 08:43 +0200, Anton Altaparmakov wrote:
>> Hi,
>>
>> > On 7 Nov 2014, at 07:52, Anand Avati <avati@gluster.org> wrote:
>> > On Thu, Nov 6, 2014 at 8:22 PM, Anton Altaparmakov <aia21@cam.ac.uk> wrote:
>> > > On 7 Nov 2014, at 01:46, Jeff Moyer <jmoyer@redhat.com> wrote:
>> > > Minor nit, but I'd rather read something that looks like this:
>> > >
>> > > if (type == READ && (flags & RWF_NONBLOCK))
>> > > return -EAGAIN;
>> > > else if (type == WRITE && (flags & RWF_DSYNC))
>> > > return -EINVAL;
>> >
>> > But your version is less logically efficient for the case where "type == READ" is true and "flags & RWF_NONBLOCK" is false because your version then has to do the "if (type == WRITE" check before discovering it does not need to take that branch either, whilst the original version does not have to do such a test at all.
>> >
>> > Seriously?
>>
>> Of course seriously.
>>
>> > Just focus on the code readability/maintainability which makes the code most easily understood/obvious to a new pair of eyes, and leave such micro-optimizations to the compiler..
>>
>> The original version is more readable (IMO) and this is not a micro-optimization. It is people like you who are responsible for the fact that we need faster and faster computers to cope with the inefficient/poor code being written more and more...
>>
>
> Your original version needs me to know that type can only be either READ
> or WRITE (and not, for instance, READONLY or READWRITE or some other
> random special case) and it rings alarm bells when I first see it. If
> you want to keep the micro optimization, you need an assertion to
> acknowledge the potential bug and a comment to make the code obvious:
>
> + assert(type == READ || type == WRITE);
> + if (type == READ) {
> + if (flags & RWF_NONBLOCK)
> + return -EAGAIN;
> + } else { /* WRITE */
> + if (flags & RWF_DSYNC)
> + return -EINVAL;
> + }
>
> but since what's really happening here is two separate and independent
> error checks, Jeff's version is still better, even if it does take an
> extra couple of nanoseconds.
>
> Actually I'd probably write:
>
> if (type == READ && (flags & RWF_NONBLOCK))
> return -EAGAIN;
>
> if (type == WRITE && (flags & RWF_DSYNC))
> return -EINVAL;
>
> (no 'else' since the code will never be reached if the first test is
> true).
>
>
> --
> Roger Willcocks <roger@filmlight.ltd.uk>
>
This is what I changed it to (and will be sending that out for the
next version).
--
Milosz Tanski
CTO
16 East 34th Street, 15th floor
New York, NY 10016
p: 646-253-9055
e: milosz@adfin.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* Re: [PATCH v8] kernel, add panic_on_warn
From: David Rientjes @ 2014-11-07 21:09 UTC (permalink / raw)
To: Prarit Bhargava
Cc: Vivek Goyal, linux-kernel, Jonathan Corbet, Andrew Morton,
Rusty Russell, H. Peter Anvin, Andi Kleen, Masami Hiramatsu,
Fabian Frederick, isimatu.yasuaki, jbaron, linux-doc, kexec,
linux-api
In-Reply-To: <545CA765.8010403@redhat.com>
On Fri, 7 Nov 2014, Prarit Bhargava wrote:
> There very much is. Consider a thread that hits a WARN() and then panics. Then
> somewhere in the panic code the thread hits another WARN() ... and then panics
> again. Previously this would have caused the system to "finish" panick'ing.
> Now it makes the system hang.
>
Then we're back to square one which is what is obviously the intent of
your patch and the comment that goes along with it: we want to clear
panic_on_warn once and not allow multiple panic(). So why not just add
the necessary synchronization to make sure that happens when WARN()
happens on two cpus simultaneously?
^ permalink raw reply
* Re: [PATCH v4 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel
From: Sakari Ailus @ 2014-11-07 22:47 UTC (permalink / raw)
To: Boris Brezillon, Mauro Carvalho Chehab, Hans Verkuil,
Laurent Pinchart, linux-media
Cc: linux-arm-kernel, linux-api, devel, linux-kernel, linux-doc,
Guennadi Liakhovetski
In-Reply-To: <1415377630-16564-1-git-send-email-boris.brezillon@free-electrons.com>
Hi Boris,
Boris Brezillon wrote:
> @@ -102,6 +113,7 @@ enum v4l2_mbus_pixelcode {
>
> V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV8888_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.
With this matter sorted out, for the set:
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Kind regards,
Sakari Ailus
sakari.ailus@iki.fi
^ permalink raw reply
* Re: [PATCH v4 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel
From: Boris Brezillon @ 2014-11-08 0:38 UTC (permalink / raw)
To: Sakari Ailus
Cc: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-api-u79uwXL29TY76Z2rM5mHXA,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA, Guennadi Liakhovetski
In-Reply-To: <545D4BFD.6000206-X3B1VOXEql0@public.gmane.org>
On Sat, 08 Nov 2014 00:47:25 +0200
Sakari Ailus <sakari.ailus-X3B1VOXEql0@public.gmane.org> wrote:
> Hi Boris,
>
> Boris Brezillon wrote:
> > @@ -102,6 +113,7 @@ enum v4l2_mbus_pixelcode {
> >
> > V4L2_MBUS_FROM_MEDIA_BUS_FMT(AHSV8888_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.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH v3 08/10] staging: media: Make use of MEDIA_BUS_FMT_ definitions
From: Prabhakar Lad @ 2014-11-08 9:11 UTC (permalink / raw)
To: Boris Brezillon
Cc: OSUOSL Drivers, LDOC, linux-api, LKML, Sakari Ailus,
Laurent Pinchart, Hans Verkuil, Mauro Carvalho Chehab,
Guennadi Liakhovetski, LAK, linux-media
In-Reply-To: <1415369269-5064-9-git-send-email-boris.brezillon@free-electrons.com>
On Fri, Nov 7, 2014 at 2:07 PM, Boris Brezillon
<boris.brezillon@free-electrons.com> 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 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.brezillon@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 ++--
For all the above
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Thanks,
--Prabhakar Lad
> 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 v4l2_mbus_pixelcode pix)
>
> static int ipipe_get_data_path(struct vpfe_ipipe_device *ipipe)
> {
> - enum v4l2_mbus_pixelcode temp_pix_fmt;
> + u32 temp_pix_fmt;
>
> switch (ipipe->formats[IPIPE_PAD_SINK].code) {
> - case V4L2_MBUS_FMT_SBGGR8_1X8:
> - case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
> - case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
> - case V4L2_MBUS_FMT_SGRBG12_1X12:
> - temp_pix_fmt = V4L2_MBUS_FMT_SGRBG12_1X12;
> + case MEDIA_BUS_FMT_SBGGR8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_SGRBG12_1X12:
> + temp_pix_fmt = MEDIA_BUS_FMT_SGRBG12_1X12;
> break;
>
> default:
> - temp_pix_fmt = V4L2_MBUS_FMT_UYVY8_2X8;
> + temp_pix_fmt = MEDIA_BUS_FMT_UYVY8_2X8;
> }
>
> - if (temp_pix_fmt == V4L2_MBUS_FMT_SGRBG12_1X12) {
> + if (temp_pix_fmt == MEDIA_BUS_FMT_SGRBG12_1X12) {
> if (ipipe->formats[IPIPE_PAD_SOURCE].code ==
> - V4L2_MBUS_FMT_SGRBG12_1X12)
> + MEDIA_BUS_FMT_SGRBG12_1X12)
> return IPIPE_RAW2RAW;
> return IPIPE_RAW2YUV;
> }
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> index 6d4893b..a86f16f 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> @@ -23,42 +23,42 @@
> #include "vpfe_mc_capture.h"
>
> static const unsigned int ipipeif_input_fmts[] = {
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_SGRBG12_1X12,
> - V4L2_MBUS_FMT_Y8_1X8,
> - V4L2_MBUS_FMT_UV8_1X8,
> - V4L2_MBUS_FMT_YDYUYDYV8_1X16,
> - V4L2_MBUS_FMT_SBGGR8_1X8,
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_SGRBG12_1X12,
> + MEDIA_BUS_FMT_Y8_1X8,
> + MEDIA_BUS_FMT_UV8_1X8,
> + MEDIA_BUS_FMT_YDYUYDYV8_1X16,
> + MEDIA_BUS_FMT_SBGGR8_1X8,
> };
>
> static const unsigned int ipipeif_output_fmts[] = {
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_SGRBG12_1X12,
> - V4L2_MBUS_FMT_Y8_1X8,
> - V4L2_MBUS_FMT_UV8_1X8,
> - V4L2_MBUS_FMT_YDYUYDYV8_1X16,
> - V4L2_MBUS_FMT_SBGGR8_1X8,
> - 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_Y8_1X8,
> + MEDIA_BUS_FMT_UV8_1X8,
> + MEDIA_BUS_FMT_YDYUYDYV8_1X16,
> + MEDIA_BUS_FMT_SBGGR8_1X8,
> + MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
> + MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
> };
>
> static int
> -ipipeif_get_pack_mode(enum v4l2_mbus_pixelcode in_pix_fmt)
> +ipipeif_get_pack_mode(u32 in_pix_fmt)
> {
> switch (in_pix_fmt) {
> - case V4L2_MBUS_FMT_SBGGR8_1X8:
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
> - case V4L2_MBUS_FMT_UV8_1X8:
> + case MEDIA_BUS_FMT_SBGGR8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_UV8_1X8:
> return IPIPEIF_5_1_PACK_8_BIT;
>
> - case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
> return IPIPEIF_5_1_PACK_8_BIT_A_LAW;
>
> - case V4L2_MBUS_FMT_SGRBG12_1X12:
> + case MEDIA_BUS_FMT_SGRBG12_1X12:
> return IPIPEIF_5_1_PACK_16_BIT;
>
> - case V4L2_MBUS_FMT_SBGGR12_1X12:
> + case MEDIA_BUS_FMT_SBGGR12_1X12:
> return IPIPEIF_5_1_PACK_12_BIT;
>
> default:
> @@ -107,8 +107,8 @@ ipipeif_get_cfg_src1(struct vpfe_ipipeif_device *ipipeif)
>
> informat = &ipipeif->formats[IPIPEIF_PAD_SINK];
> if (ipipeif->input == IPIPEIF_INPUT_MEMORY &&
> - (informat->code == V4L2_MBUS_FMT_Y8_1X8 ||
> - informat->code == V4L2_MBUS_FMT_UV8_1X8))
> + (informat->code == MEDIA_BUS_FMT_Y8_1X8 ||
> + informat->code == MEDIA_BUS_FMT_UV8_1X8))
> return IPIPEIF_CCDC;
>
> return IPIPEIF_SRC1_PARALLEL_PORT;
> @@ -122,11 +122,11 @@ ipipeif_get_data_shift(struct vpfe_ipipeif_device *ipipeif)
> informat = &ipipeif->formats[IPIPEIF_PAD_SINK];
>
> switch (informat->code) {
> - case V4L2_MBUS_FMT_SGRBG12_1X12:
> + case MEDIA_BUS_FMT_SGRBG12_1X12:
> return IPIPEIF_5_1_BITS11_0;
>
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_UV8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_UV8_1X8:
> return IPIPEIF_5_1_BITS11_0;
>
> default:
> @@ -143,7 +143,7 @@ ipipeif_get_source(struct vpfe_ipipeif_device *ipipeif)
> if (ipipeif->input == IPIPEIF_INPUT_ISIF)
> return IPIPEIF_CCDC;
>
> - if (informat->code == V4L2_MBUS_FMT_UYVY8_2X8)
> + if (informat->code == MEDIA_BUS_FMT_UYVY8_2X8)
> return IPIPEIF_SDRAM_YUV;
>
> return IPIPEIF_SDRAM_RAW;
> @@ -190,7 +190,7 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
> struct v4l2_mbus_framefmt *informat, *outformat;
> struct ipipeif_params params = ipipeif->config;
> enum ipipeif_input_source ipipeif_source;
> - enum v4l2_mbus_pixelcode isif_port_if;
> + u32 isif_port_if;
> void *ipipeif_base_addr;
> unsigned int val;
> int data_shift;
> @@ -268,16 +268,16 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
> ipipeif_write(val, ipipeif_base_addr, IPIPEIF_INIRSZ);
> isif_port_if = informat->code;
>
> - if (isif_port_if == V4L2_MBUS_FMT_Y8_1X8)
> - isif_port_if = V4L2_MBUS_FMT_YUYV8_1X16;
> - else if (isif_port_if == V4L2_MBUS_FMT_UV8_1X8)
> - isif_port_if = V4L2_MBUS_FMT_SGRBG12_1X12;
> + if (isif_port_if == MEDIA_BUS_FMT_Y8_1X8)
> + isif_port_if = MEDIA_BUS_FMT_YUYV8_1X16;
> + else if (isif_port_if == MEDIA_BUS_FMT_UV8_1X8)
> + isif_port_if = MEDIA_BUS_FMT_SGRBG12_1X12;
>
> /* Enable DPCM decompression */
> switch (ipipeif_source) {
> case IPIPEIF_SDRAM_RAW:
> val = 0;
> - if (outformat->code == V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8) {
> + if (outformat->code == MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8) {
> val = 1;
> val |= (IPIPEIF_DPCM_8BIT_10BIT & 1) <<
> IPIPEIF_DPCM_BITS_SHIFT;
> @@ -296,9 +296,9 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
> /* configure CFG2 */
> val = ipipeif_read(ipipeif_base_addr, IPIPEIF_CFG2);
> switch (isif_port_if) {
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> - case V4L2_MBUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
> @@ -344,16 +344,16 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
> val |= VPFE_PINPOL_POSITIVE << IPIPEIF_CFG2_VDPOL_SHIFT;
>
> switch (isif_port_if) {
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> - case V4L2_MBUS_FMT_YUYV10_1X20:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_YUYV10_1X20:
> RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> break;
>
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_YUYV10_2X10:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_YUYV10_2X10:
> SETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> val |= IPIPEIF_CBCR_Y << IPIPEIF_CFG2_YUV8P_SHIFT;
> @@ -625,7 +625,7 @@ ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif,
>
> /* If not found, use SBGGR10 as default */
> if (i >= ARRAY_SIZE(ipipeif_input_fmts))
> - fmt->code = V4L2_MBUS_FMT_SGRBG12_1X12;
> + fmt->code = MEDIA_BUS_FMT_SGRBG12_1X12;
> } else if (pad == IPIPEIF_PAD_SOURCE) {
> for (i = 0; i < ARRAY_SIZE(ipipeif_output_fmts); i++)
> if (fmt->code == ipipeif_output_fmts[i])
> @@ -633,7 +633,7 @@ ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif,
>
> /* If not found, use UYVY as default */
> if (i >= ARRAY_SIZE(ipipeif_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);
> @@ -770,7 +770,7 @@ ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
> memset(&format, 0, sizeof(format));
> format.pad = IPIPEIF_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;
> ipipeif_set_format(sd, fh, &format);
> @@ -778,7 +778,7 @@ ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
> memset(&format, 0, sizeof(format));
> format.pad = IPIPEIF_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;
> ipipeif_set_format(sd, fh, &format);
> @@ -805,9 +805,9 @@ ipipeif_video_in_queue(struct vpfe_device *vpfe_dev, unsigned long addr)
> return -EINVAL;
>
> switch (ipipeif->formats[IPIPEIF_PAD_SINK].code) {
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_UV8_1X8:
> - case V4L2_MBUS_FMT_YDYUYDYV8_1X16:
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_UV8_1X8:
> + case MEDIA_BUS_FMT_YDYUYDYV8_1X16:
> adofs = ipipeif->formats[IPIPEIF_PAD_SINK].width;
> break;
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c
> index 0d535b0..fa26f63 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
> @@ -27,13 +27,13 @@
> #define MAX_HEIGHT 4096
>
> static const unsigned int isif_fmts[] = {
> - V4L2_MBUS_FMT_YUYV8_2X8,
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_YUYV8_1X16,
> - V4L2_MBUS_FMT_YUYV10_1X20,
> - V4L2_MBUS_FMT_SGRBG12_1X12,
> - V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
> - V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
> + MEDIA_BUS_FMT_YUYV8_2X8,
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_YUYV8_1X16,
> + MEDIA_BUS_FMT_YUYV10_1X20,
> + MEDIA_BUS_FMT_SGRBG12_1X12,
> + MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
> + MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
> };
>
> #define ISIF_COLPTN_R_Ye 0x0
> @@ -154,7 +154,7 @@ enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev)
> static int
> isif_set_pixel_format(struct vpfe_isif_device *isif, unsigned int pixfmt)
> {
> - if (isif->formats[ISIF_PAD_SINK].code == V4L2_MBUS_FMT_SGRBG12_1X12) {
> + if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12) {
> if (pixfmt == V4L2_PIX_FMT_SBGGR16)
> isif->isif_cfg.data_pack = ISIF_PACK_16BIT;
> else if ((pixfmt == V4L2_PIX_FMT_SGRBG10DPCM8) ||
> @@ -184,7 +184,7 @@ static int
> isif_set_frame_format(struct vpfe_isif_device *isif,
> enum isif_frmfmt frm_fmt)
> {
> - if (isif->formats[ISIF_PAD_SINK].code == V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12)
> isif->isif_cfg.bayer.frm_fmt = frm_fmt;
> else
> isif->isif_cfg.ycbcr.frm_fmt = frm_fmt;
> @@ -196,7 +196,7 @@ static int isif_set_image_window(struct vpfe_isif_device *isif)
> {
> struct v4l2_rect *win = &isif->crop;
>
> - if (isif->formats[ISIF_PAD_SINK].code == V4L2_MBUS_FMT_SGRBG12_1X12) {
> + if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12) {
> isif->isif_cfg.bayer.win.top = win->top;
> isif->isif_cfg.bayer.win.left = win->left;
> isif->isif_cfg.bayer.win.width = win->width;
> @@ -214,7 +214,7 @@ static int isif_set_image_window(struct vpfe_isif_device *isif)
> static int
> isif_set_buftype(struct vpfe_isif_device *isif, enum isif_buftype buf_type)
> {
> - if (isif->formats[ISIF_PAD_SINK].code == V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12)
> isif->isif_cfg.bayer.buf_type = buf_type;
> else
> isif->isif_cfg.ycbcr.buf_type = buf_type;
> @@ -296,7 +296,7 @@ isif_try_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh,
>
> /* If not found, use YUYV8_2x8 as default */
> if (i >= ARRAY_SIZE(isif_fmts))
> - fmt->format.code = V4L2_MBUS_FMT_YUYV8_2X8;
> + fmt->format.code = MEDIA_BUS_FMT_YUYV8_2X8;
>
> /* Clamp the size. */
> fmt->format.width = clamp_t(u32, width, 32, MAX_WIDTH);
> @@ -429,7 +429,7 @@ static int isif_get_params(struct v4l2_subdev *sd, void *params)
> struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
>
> /* only raw module parameters can be set through the IOCTL */
> - if (isif->formats[ISIF_PAD_SINK].code != V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (isif->formats[ISIF_PAD_SINK].code != MEDIA_BUS_FMT_SGRBG12_1X12)
> return -EINVAL;
> memcpy(params, &isif->isif_cfg.bayer.config_params,
> sizeof(isif->isif_cfg.bayer.config_params));
> @@ -604,7 +604,7 @@ static int isif_set_params(struct v4l2_subdev *sd, void *params)
> int ret = -EINVAL;
>
> /* only raw module parameters can be set through the IOCTL */
> - if (isif->formats[ISIF_PAD_SINK].code != V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (isif->formats[ISIF_PAD_SINK].code != MEDIA_BUS_FMT_SGRBG12_1X12)
> return ret;
>
> memcpy(&isif_raw_params, params, sizeof(isif_raw_params));
> @@ -1041,19 +1041,19 @@ isif_config_culling(struct vpfe_isif_device *isif, struct vpfe_isif_cul *cul)
> static int isif_get_pix_fmt(u32 mbus_code)
> {
> switch (mbus_code) {
> - 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 ISIF_PIXFMT_RAW;
>
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> - case V4L2_MBUS_FMT_YUYV10_2X10:
> - case V4L2_MBUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_YUYV10_2X10:
> + case MEDIA_BUS_FMT_Y8_1X8:
> return ISIF_PIXFMT_YCBCR_8BIT;
>
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> - case V4L2_MBUS_FMT_YUYV10_1X20:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_YUYV10_1X20:
> return ISIF_PIXFMT_YCBCR_16BIT;
>
> default:
> @@ -1121,11 +1121,11 @@ static int isif_config_raw(struct v4l2_subdev *sd, int mode)
> ISIF_FRM_FMT_MASK) << ISIF_FRM_FMT_SHIFT) | ((pix_fmt &
> ISIF_INPUT_MASK) << ISIF_INPUT_SHIFT);
>
> - /* currently only V4L2_MBUS_FMT_SGRBG12_1X12 is
> + /* currently only MEDIA_BUS_FMT_SGRBG12_1X12 is
> * supported. shift appropriately depending on
> * different MBUS fmt's added
> */
> - if (format->code == V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (format->code == MEDIA_BUS_FMT_SGRBG12_1X12)
> val |= ((VPFE_ISIF_NO_SHIFT &
> ISIF_DATASFT_MASK) << ISIF_DATASFT_SHIFT);
>
> @@ -1154,7 +1154,7 @@ static int isif_config_raw(struct v4l2_subdev *sd, int mode)
> /* Configure Gain & Offset */
> isif_config_gain_offset(isif);
> /* Configure Color pattern */
> - if (format->code == V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (format->code == MEDIA_BUS_FMT_SGRBG12_1X12)
> val = isif_sgrbg_pattern;
> else
> /* default set to rggb */
> @@ -1254,8 +1254,8 @@ static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
> (((params->vd_pol & ISIF_VD_POL_MASK) << ISIF_VD_POL_SHIFT));
> /* pack the data to 8-bit CCDCCFG */
> switch (format->code) {
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> if (pix_fmt != ISIF_PIXFMT_YCBCR_8BIT) {
> pr_debug("Invalid pix_fmt(input mode)\n");
> return -EINVAL;
> @@ -1266,7 +1266,7 @@ static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
> ccdcfg = ccdcfg | ISIF_PACK_8BIT | ISIF_YCINSWP_YCBCR;
> break;
>
> - case V4L2_MBUS_FMT_YUYV10_2X10:
> + case MEDIA_BUS_FMT_YUYV10_2X10:
> if (pix_fmt != ISIF_PIXFMT_YCBCR_8BIT) {
> pr_debug("Invalid pix_fmt(input mode)\n");
> return -EINVAL;
> @@ -1278,7 +1278,7 @@ static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
> ISIF_BW656_ENABLE;
> break;
>
> - case V4L2_MBUS_FMT_YUYV10_1X20:
> + case MEDIA_BUS_FMT_YUYV10_1X20:
> if (pix_fmt != ISIF_PIXFMT_YCBCR_16BIT) {
> pr_debug("Invalid pix_fmt(input mode)\n");
> return -EINVAL;
> @@ -1286,7 +1286,7 @@ static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
> isif_write(isif->isif_cfg.base_addr, 3, REC656IF);
> break;
>
> - case V4L2_MBUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> ccdcfg |= ISIF_PACK_8BIT;
> ccdcfg |= ISIF_YCINSWP_YCBCR;
> if (pix_fmt != ISIF_PIXFMT_YCBCR_8BIT) {
> @@ -1295,7 +1295,7 @@ static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
> }
> break;
>
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> if (pix_fmt != ISIF_PIXFMT_YCBCR_16BIT) {
> pr_debug("Invalid pix_fmt(input mode)\n");
> return -EINVAL;
> @@ -1313,8 +1313,8 @@ static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
> ISIF_PIX_ORDER_SHIFT;
> isif_write(isif->isif_cfg.base_addr, ccdcfg, CCDCFG);
> /* configure video window */
> - if (format->code == V4L2_MBUS_FMT_YUYV10_1X20 ||
> - format->code == V4L2_MBUS_FMT_YUYV8_1X16)
> + if (format->code == MEDIA_BUS_FMT_YUYV10_1X20 ||
> + format->code == MEDIA_BUS_FMT_YUYV8_1X16)
> isif_setwin(isif, ¶ms->win, params->frm_fmt, 1, mode);
> else
> isif_setwin(isif, ¶ms->win, params->frm_fmt, 2, mode);
> @@ -1345,17 +1345,17 @@ static int isif_configure(struct v4l2_subdev *sd, int mode)
> format = &isif->formats[ISIF_PAD_SINK];
>
> switch (format->code) {
> - 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 isif_config_raw(sd, mode);
>
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> - case V4L2_MBUS_FMT_YUYV10_2X10:
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> - case V4L2_MBUS_FMT_YUYV10_1X20:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_YUYV10_2X10:
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_YUYV10_1X20:
> return isif_config_ycbcr(sd, mode);
>
> default:
> @@ -1630,7 +1630,7 @@ isif_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = ISIF_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 = MAX_WIDTH;
> format.format.height = MAX_HEIGHT;
> isif_set_format(sd, fh, &format);
> @@ -1638,7 +1638,7 @@ isif_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = ISIF_PAD_SOURCE;
> 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 = MAX_WIDTH;
> format.format.height = MAX_HEIGHT;
> isif_set_format(sd, fh, &format);
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
> index 8828d6c..e0b29c8 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
> @@ -35,18 +35,18 @@
> #define MIN_OUT_HEIGHT 2
>
> static const unsigned int resizer_input_formats[] = {
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_Y8_1X8,
> - V4L2_MBUS_FMT_UV8_1X8,
> - V4L2_MBUS_FMT_SGRBG12_1X12,
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_Y8_1X8,
> + MEDIA_BUS_FMT_UV8_1X8,
> + MEDIA_BUS_FMT_SGRBG12_1X12,
> };
>
> static const unsigned int resizer_output_formats[] = {
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_Y8_1X8,
> - V4L2_MBUS_FMT_UV8_1X8,
> - V4L2_MBUS_FMT_YDYUYDYV8_1X16,
> - V4L2_MBUS_FMT_SGRBG12_1X12,
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_Y8_1X8,
> + MEDIA_BUS_FMT_UV8_1X8,
> + MEDIA_BUS_FMT_YDYUYDYV8_1X16,
> + MEDIA_BUS_FMT_SGRBG12_1X12,
> };
>
> /* resizer_calculate_line_length() - This function calculates the line length of
> @@ -54,17 +54,17 @@ static const unsigned int resizer_output_formats[] = {
> * output.
> */
> static void
> -resizer_calculate_line_length(enum v4l2_mbus_pixelcode pix, int width,
> - int height, int *line_len, int *line_len_c)
> +resizer_calculate_line_length(u32 pix, int width, int height,
> + int *line_len, int *line_len_c)
> {
> *line_len = 0;
> *line_len_c = 0;
>
> - if (pix == V4L2_MBUS_FMT_UYVY8_2X8 ||
> - pix == V4L2_MBUS_FMT_SGRBG12_1X12) {
> + if (pix == MEDIA_BUS_FMT_UYVY8_2X8 ||
> + pix == MEDIA_BUS_FMT_SGRBG12_1X12) {
> *line_len = width << 1;
> - } else if (pix == V4L2_MBUS_FMT_Y8_1X8 ||
> - pix == V4L2_MBUS_FMT_UV8_1X8) {
> + } else if (pix == MEDIA_BUS_FMT_Y8_1X8 ||
> + pix == MEDIA_BUS_FMT_UV8_1X8) {
> *line_len = width;
> *line_len_c = width;
> } else {
> @@ -85,11 +85,11 @@ resizer_validate_output_image_format(struct device *dev,
> struct v4l2_mbus_framefmt *format,
> int *in_line_len, int *in_line_len_c)
> {
> - if (format->code != V4L2_MBUS_FMT_UYVY8_2X8 &&
> - format->code != V4L2_MBUS_FMT_Y8_1X8 &&
> - format->code != V4L2_MBUS_FMT_UV8_1X8 &&
> - format->code != V4L2_MBUS_FMT_YDYUYDYV8_1X16 &&
> - format->code != V4L2_MBUS_FMT_SGRBG12_1X12) {
> + if (format->code != MEDIA_BUS_FMT_UYVY8_2X8 &&
> + format->code != MEDIA_BUS_FMT_Y8_1X8 &&
> + format->code != MEDIA_BUS_FMT_UV8_1X8 &&
> + format->code != MEDIA_BUS_FMT_YDYUYDYV8_1X16 &&
> + format->code != MEDIA_BUS_FMT_SGRBG12_1X12) {
> dev_err(dev, "Invalid Mbus format, %d\n", format->code);
> return -EINVAL;
> }
> @@ -281,7 +281,7 @@ resizer_calculate_sdram_offsets(struct vpfe_resizer_device *resizer, int index)
> param->ext_mem_param[index].c_offset = 0;
> param->ext_mem_param[index].flip_ofst_y = 0;
> param->ext_mem_param[index].flip_ofst_c = 0;
> - if (outformat->code == V4L2_MBUS_FMT_YDYUYDYV8_1X16) {
> + if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16) {
> /* YUV 420 */
> yuv_420 = 1;
> bytesperpixel = 1;
> @@ -322,7 +322,7 @@ static int resizer_configure_output_win(struct vpfe_resizer_device *resizer)
> outformat = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE];
>
> output_specs.vst_y = param->user_config.vst;
> - if (outformat->code == V4L2_MBUS_FMT_YDYUYDYV8_1X16)
> + if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
> output_specs.vst_c = param->user_config.vst;
>
> configure_resizer_out_params(resizer, RSZ_A, &output_specs, 0, 0);
> @@ -336,7 +336,7 @@ static int resizer_configure_output_win(struct vpfe_resizer_device *resizer)
> if (param->rsz_en[RSZ_B])
> resizer_calculate_resize_ratios(resizer, RSZ_B);
>
> - if (outformat->code == V4L2_MBUS_FMT_YDYUYDYV8_1X16)
> + if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
> resizer_enable_422_420_conversion(param, RSZ_A, ENABLE);
> else
> resizer_enable_422_420_conversion(param, RSZ_A, DISABLE);
> @@ -447,26 +447,26 @@ resizer_configure_common_in_params(struct vpfe_resizer_device *resizer)
> param->rsz_common.source = IPIPE_DATA;
>
> switch (informat->code) {
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> param->rsz_common.src_img_fmt = RSZ_IMG_422;
> param->rsz_common.raw_flip = 0;
> break;
>
> - case V4L2_MBUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> param->rsz_common.src_img_fmt = RSZ_IMG_420;
> /* Select y */
> param->rsz_common.y_c = 0;
> param->rsz_common.raw_flip = 0;
> break;
>
> - case V4L2_MBUS_FMT_UV8_1X8:
> + case MEDIA_BUS_FMT_UV8_1X8:
> param->rsz_common.src_img_fmt = RSZ_IMG_420;
> /* Select y */
> param->rsz_common.y_c = 1;
> param->rsz_common.raw_flip = 0;
> break;
>
> - case V4L2_MBUS_FMT_SGRBG12_1X12:
> + case MEDIA_BUS_FMT_SGRBG12_1X12:
> param->rsz_common.raw_flip = 1;
> break;
>
> @@ -519,7 +519,7 @@ resizer_configure_in_continious_mode(struct vpfe_resizer_device *resizer)
> param->ext_mem_param[RSZ_B].rsz_sdr_oft_c = line_len_c;
> configure_resizer_out_params(resizer, RSZ_B,
> &cont_config->output2, 0, 1);
> - if (outformat2->code == V4L2_MBUS_FMT_YDYUYDYV8_1X16)
> + if (outformat2->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
> resizer_enable_422_420_conversion(param,
> RSZ_B, ENABLE);
> else
> @@ -540,15 +540,15 @@ resizer_configure_in_continious_mode(struct vpfe_resizer_device *resizer)
>
> static inline int
> resizer_validate_input_image_format(struct device *dev,
> - enum v4l2_mbus_pixelcode pix,
> + u32 pix,
> int width, int height, int *line_len)
> {
> int val;
>
> - if (pix != V4L2_MBUS_FMT_UYVY8_2X8 &&
> - pix != V4L2_MBUS_FMT_Y8_1X8 &&
> - pix != V4L2_MBUS_FMT_UV8_1X8 &&
> - pix != V4L2_MBUS_FMT_SGRBG12_1X12) {
> + if (pix != MEDIA_BUS_FMT_UYVY8_2X8 &&
> + pix != MEDIA_BUS_FMT_Y8_1X8 &&
> + pix != MEDIA_BUS_FMT_UV8_1X8 &&
> + pix != MEDIA_BUS_FMT_SGRBG12_1X12) {
> dev_err(dev,
> "resizer validate output: pix format not supported, %d\n", pix);
> return -EINVAL;
> @@ -560,7 +560,7 @@ resizer_validate_input_image_format(struct device *dev,
> return -EINVAL;
> }
>
> - if (pix == V4L2_MBUS_FMT_UV8_1X8)
> + if (pix == MEDIA_BUS_FMT_UV8_1X8)
> resizer_calculate_line_length(pix, width,
> height, &val, line_len);
> else
> @@ -709,12 +709,12 @@ resizer_configure_in_single_shot_mode(struct vpfe_resizer_device *resizer)
> configure_resizer_out_params(resizer, RSZ_A,
> ¶m->user_config.output1, 0, 1);
>
> - if (outformat1->code == V4L2_MBUS_FMT_SGRBG12_1X12)
> + if (outformat1->code == MEDIA_BUS_FMT_SGRBG12_1X12)
> param->rsz_common.raw_flip = 1;
> else
> param->rsz_common.raw_flip = 0;
>
> - if (outformat1->code == V4L2_MBUS_FMT_YDYUYDYV8_1X16)
> + if (outformat1->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
> resizer_enable_422_420_conversion(param,
> RSZ_A, ENABLE);
> else
> @@ -732,7 +732,7 @@ resizer_configure_in_single_shot_mode(struct vpfe_resizer_device *resizer)
> param->ext_mem_param[RSZ_B].rsz_sdr_oft_c = line_len_c;
> configure_resizer_out_params(resizer, RSZ_B,
> ¶m->user_config.output2, 0, 1);
> - if (outformat2->code == V4L2_MBUS_FMT_YDYUYDYV8_1X16)
> + if (outformat2->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
> resizer_enable_422_420_conversion(param,
> RSZ_B, ENABLE);
> else
> @@ -745,7 +745,7 @@ resizer_configure_in_single_shot_mode(struct vpfe_resizer_device *resizer)
> resizer_calculate_resize_ratios(resizer, RSZ_A);
> resizer_calculate_sdram_offsets(resizer, RSZ_A);
> /* Overriding resize ratio calculation */
> - if (informat->code == V4L2_MBUS_FMT_UV8_1X8) {
> + if (informat->code == MEDIA_BUS_FMT_UV8_1X8) {
> param->rsz_rsc_param[RSZ_A].v_dif =
> (((informat->height + 1) * 2) * 256) /
> (param->rsz_rsc_param[RSZ_A].o_vsz + 1);
> @@ -756,7 +756,7 @@ resizer_configure_in_single_shot_mode(struct vpfe_resizer_device *resizer)
> resizer_calculate_resize_ratios(resizer, RSZ_B);
> resizer_calculate_sdram_offsets(resizer, RSZ_B);
> /* Overriding resize ratio calculation */
> - if (informat->code == V4L2_MBUS_FMT_UV8_1X8) {
> + if (informat->code == MEDIA_BUS_FMT_UV8_1X8) {
> param->rsz_rsc_param[RSZ_B].v_dif =
> (((informat->height + 1) * 2) * 256) /
> (param->rsz_rsc_param[RSZ_B].o_vsz + 1);
> @@ -1340,7 +1340,7 @@ resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
> }
> /* If not found, use UYVY as default */
> if (i >= ARRAY_SIZE(resizer_input_formats))
> - fmt->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
>
> fmt->width = clamp_t(u32, fmt->width, MIN_IN_WIDTH,
> MAX_IN_WIDTH);
> @@ -1357,7 +1357,7 @@ resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
> }
> /* If not found, use UYVY as default */
> if (i >= ARRAY_SIZE(resizer_output_formats))
> - fmt->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
>
> fmt->width = clamp_t(u32, fmt->width, MIN_OUT_WIDTH,
> max_out_width);
> @@ -1375,7 +1375,7 @@ resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
> }
> /* If not found, use UYVY as default */
> if (i >= ARRAY_SIZE(resizer_output_formats))
> - fmt->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
>
> fmt->width = clamp_t(u32, fmt->width, MIN_OUT_WIDTH,
> max_out_width);
> @@ -1548,7 +1548,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_CROP_PAD_SINK;
> format.which = which;
> - format.format.code = V4L2_MBUS_FMT_YUYV8_2X8;
> + format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
> format.format.width = MAX_IN_WIDTH;
> format.format.height = MAX_IN_HEIGHT;
> resizer_set_format(sd, fh, &format);
> @@ -1556,7 +1556,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_CROP_PAD_SOURCE;
> format.which = which;
> - format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
> + format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> format.format.width = MAX_IN_WIDTH;
> format.format.height = MAX_IN_WIDTH;
> resizer_set_format(sd, fh, &format);
> @@ -1564,7 +1564,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_CROP_PAD_SOURCE2;
> format.which = which;
> - format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
> + format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> format.format.width = MAX_IN_WIDTH;
> format.format.height = MAX_IN_WIDTH;
> resizer_set_format(sd, fh, &format);
> @@ -1572,7 +1572,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_PAD_SINK;
> format.which = which;
> - format.format.code = V4L2_MBUS_FMT_YUYV8_2X8;
> + format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
> format.format.width = MAX_IN_WIDTH;
> format.format.height = MAX_IN_HEIGHT;
> resizer_set_format(sd, fh, &format);
> @@ -1580,7 +1580,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_PAD_SOURCE;
> format.which = which;
> - 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;
> resizer_set_format(sd, fh, &format);
> @@ -1588,7 +1588,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_PAD_SINK;
> format.which = which;
> - format.format.code = V4L2_MBUS_FMT_YUYV8_2X8;
> + format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
> format.format.width = MAX_IN_WIDTH;
> format.format.height = MAX_IN_HEIGHT;
> resizer_set_format(sd, fh, &format);
> @@ -1596,7 +1596,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_PAD_SOURCE;
> format.which = which;
> - format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
> + format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> format.format.width = IPIPE_MAX_OUTPUT_WIDTH_B;
> format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_B;
> resizer_set_format(sd, fh, &format);
> diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
> index a862b28..bf45d2c 100644
> --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
> +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
> @@ -99,47 +99,47 @@ void mbus_to_pix(const struct v4l2_mbus_framefmt *mbus,
> struct v4l2_pix_format *pix)
> {
> switch (mbus->code) {
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> pix->pixelformat = V4L2_PIX_FMT_UYVY;
> pix->bytesperline = pix->width * 2;
> break;
>
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> pix->pixelformat = V4L2_PIX_FMT_YUYV;
> pix->bytesperline = pix->width * 2;
> break;
>
> - case V4L2_MBUS_FMT_YUYV10_1X20:
> + case MEDIA_BUS_FMT_YUYV10_1X20:
> pix->pixelformat = V4L2_PIX_FMT_UYVY;
> pix->bytesperline = pix->width * 2;
> break;
>
> - case V4L2_MBUS_FMT_SGRBG12_1X12:
> + case MEDIA_BUS_FMT_SGRBG12_1X12:
> pix->pixelformat = V4L2_PIX_FMT_SBGGR16;
> pix->bytesperline = pix->width * 2;
> break;
>
> - case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
> pix->pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8;
> pix->bytesperline = pix->width;
> break;
>
> - case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
> pix->pixelformat = V4L2_PIX_FMT_SGRBG10ALAW8;
> pix->bytesperline = pix->width;
> break;
>
> - case V4L2_MBUS_FMT_YDYUYDYV8_1X16:
> + case MEDIA_BUS_FMT_YDYUYDYV8_1X16:
> pix->pixelformat = V4L2_PIX_FMT_NV12;
> pix->bytesperline = pix->width;
> break;
>
> - case V4L2_MBUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> pix->pixelformat = V4L2_PIX_FMT_GREY;
> pix->bytesperline = pix->width;
> break;
>
> - case V4L2_MBUS_FMT_UV8_1X8:
> + case MEDIA_BUS_FMT_UV8_1X8:
> pix->pixelformat = V4L2_PIX_FMT_UV8;
> pix->bytesperline = pix->width;
> break;
> diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
> index 92c2d5b..7dbf68c 100644
> --- a/drivers/staging/media/omap4iss/iss_csi2.c
> +++ b/drivers/staging/media/omap4iss/iss_csi2.c
> @@ -93,20 +93,20 @@ static void csi2_recv_config(struct iss_csi2_device *csi2,
> }
>
> static const unsigned int csi2_input_fmts[] = {
> - V4L2_MBUS_FMT_SGRBG10_1X10,
> - V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
> - V4L2_MBUS_FMT_SRGGB10_1X10,
> - V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8,
> - V4L2_MBUS_FMT_SBGGR10_1X10,
> - V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8,
> - V4L2_MBUS_FMT_SGBRG10_1X10,
> - V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8,
> - V4L2_MBUS_FMT_SBGGR8_1X8,
> - V4L2_MBUS_FMT_SGBRG8_1X8,
> - V4L2_MBUS_FMT_SGRBG8_1X8,
> - V4L2_MBUS_FMT_SRGGB8_1X8,
> - V4L2_MBUS_FMT_UYVY8_1X16,
> - V4L2_MBUS_FMT_YUYV8_1X16,
> + MEDIA_BUS_FMT_SGRBG10_1X10,
> + MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
> + MEDIA_BUS_FMT_SRGGB10_1X10,
> + MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8,
> + MEDIA_BUS_FMT_SBGGR10_1X10,
> + MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8,
> + MEDIA_BUS_FMT_SGBRG10_1X10,
> + MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8,
> + MEDIA_BUS_FMT_SBGGR8_1X8,
> + MEDIA_BUS_FMT_SGBRG8_1X8,
> + MEDIA_BUS_FMT_SGRBG8_1X8,
> + MEDIA_BUS_FMT_SRGGB8_1X8,
> + MEDIA_BUS_FMT_UYVY8_1X16,
> + MEDIA_BUS_FMT_YUYV8_1X16,
> };
>
> /* To set the format on the CSI2 requires a mapping function that takes
> @@ -201,26 +201,26 @@ static u16 csi2_ctx_map_format(struct iss_csi2_device *csi2)
> int fmtidx, destidx;
>
> switch (fmt->code) {
> - case V4L2_MBUS_FMT_SGRBG10_1X10:
> - case V4L2_MBUS_FMT_SRGGB10_1X10:
> - case V4L2_MBUS_FMT_SBGGR10_1X10:
> - case V4L2_MBUS_FMT_SGBRG10_1X10:
> + case MEDIA_BUS_FMT_SGRBG10_1X10:
> + case MEDIA_BUS_FMT_SRGGB10_1X10:
> + case MEDIA_BUS_FMT_SBGGR10_1X10:
> + case MEDIA_BUS_FMT_SGBRG10_1X10:
> fmtidx = 0;
> break;
> - case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
> - case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
> - case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
> - case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
> + case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
> fmtidx = 1;
> 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:
> fmtidx = 2;
> break;
> - case V4L2_MBUS_FMT_UYVY8_1X16:
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_UYVY8_1X16:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> fmtidx = 3;
> break;
> default:
> @@ -817,7 +817,7 @@ csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh,
> unsigned int pad, struct v4l2_mbus_framefmt *fmt,
> enum v4l2_subdev_format_whence which)
> {
> - enum v4l2_mbus_pixelcode pixelcode;
> + u32 pixelcode;
> struct v4l2_mbus_framefmt *format;
> const struct iss_format_info *info;
> unsigned int i;
> @@ -832,7 +832,7 @@ csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh,
>
> /* If not found, use SGRBG10 as default */
> if (i >= ARRAY_SIZE(csi2_input_fmts))
> - fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
>
> fmt->width = clamp_t(u32, fmt->width, 1, 8191);
> fmt->height = clamp_t(u32, fmt->height, 1, 8191);
> @@ -1020,7 +1020,7 @@ static int csi2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
> memset(&format, 0, sizeof(format));
> format.pad = CSI2_PAD_SINK;
> format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
> - format.format.code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
> format.format.width = 4096;
> format.format.height = 4096;
> csi2_set_format(sd, fh, &format);
> diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c
> index 5404200..a1a46ef 100644
> --- a/drivers/staging/media/omap4iss/iss_ipipe.c
> +++ b/drivers/staging/media/omap4iss/iss_ipipe.c
> @@ -28,10 +28,10 @@ __ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh,
> unsigned int pad, enum v4l2_subdev_format_whence which);
>
> static const unsigned int ipipe_fmts[] = {
> - V4L2_MBUS_FMT_SGRBG10_1X10,
> - V4L2_MBUS_FMT_SRGGB10_1X10,
> - V4L2_MBUS_FMT_SBGGR10_1X10,
> - V4L2_MBUS_FMT_SGBRG10_1X10,
> + MEDIA_BUS_FMT_SGRBG10_1X10,
> + MEDIA_BUS_FMT_SRGGB10_1X10,
> + MEDIA_BUS_FMT_SBGGR10_1X10,
> + MEDIA_BUS_FMT_SGBRG10_1X10,
> };
>
> /*
> @@ -211,7 +211,7 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh,
>
> /* If not found, use SGRBG10 as default */
> if (i >= ARRAY_SIZE(ipipe_fmts))
> - fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
>
> /* Clamp the input size. */
> fmt->width = clamp_t(u32, width, 1, 8192);
> @@ -223,7 +223,7 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh,
> format = __ipipe_get_format(ipipe, fh, IPIPE_PAD_SINK, which);
> memcpy(fmt, format, sizeof(*fmt));
>
> - fmt->code = V4L2_MBUS_FMT_UYVY8_1X16;
> + fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
> fmt->width = clamp_t(u32, width, 32, fmt->width);
> fmt->height = clamp_t(u32, height, 32, fmt->height);
> fmt->colorspace = V4L2_COLORSPACE_JPEG;
> @@ -257,7 +257,7 @@ static int ipipe_enum_mbus_code(struct v4l2_subdev *sd,
> if (code->index != 0)
> return -EINVAL;
>
> - code->code = V4L2_MBUS_FMT_UYVY8_1X16;
> + code->code = MEDIA_BUS_FMT_UYVY8_1X16;
> break;
>
> default:
> @@ -385,7 +385,7 @@ static int 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_SGRBG10_1X10;
> + format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
> format.format.width = 4096;
> format.format.height = 4096;
> ipipe_set_format(sd, fh, &format);
> diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c
> index 75f6a15..32a7483 100644
> --- a/drivers/staging/media/omap4iss/iss_ipipeif.c
> +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c
> @@ -24,12 +24,12 @@
> #include "iss_ipipeif.h"
>
> static const unsigned int ipipeif_fmts[] = {
> - V4L2_MBUS_FMT_SGRBG10_1X10,
> - V4L2_MBUS_FMT_SRGGB10_1X10,
> - V4L2_MBUS_FMT_SBGGR10_1X10,
> - V4L2_MBUS_FMT_SGBRG10_1X10,
> - V4L2_MBUS_FMT_UYVY8_1X16,
> - V4L2_MBUS_FMT_YUYV8_1X16,
> + MEDIA_BUS_FMT_SGRBG10_1X10,
> + MEDIA_BUS_FMT_SRGGB10_1X10,
> + MEDIA_BUS_FMT_SBGGR10_1X10,
> + MEDIA_BUS_FMT_SGBRG10_1X10,
> + MEDIA_BUS_FMT_UYVY8_1X16,
> + MEDIA_BUS_FMT_YUYV8_1X16,
> };
>
> /*
> @@ -140,8 +140,8 @@ static void ipipeif_configure(struct iss_ipipeif_device *ipipeif)
>
> /* Select ISIF/IPIPEIF input format */
> switch (format->code) {
> - case V4L2_MBUS_FMT_UYVY8_1X16:
> - case V4L2_MBUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_UYVY8_1X16:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> iss_reg_update(iss, OMAP4_ISS_MEM_ISP_ISIF, ISIF_MODESET,
> ISIF_MODESET_CCDMD | ISIF_MODESET_INPMOD_MASK |
> ISIF_MODESET_CCDW_MASK,
> @@ -151,25 +151,25 @@ static void ipipeif_configure(struct iss_ipipeif_device *ipipeif)
> IPIPEIF_CFG2_YUV8, IPIPEIF_CFG2_YUV16);
>
> break;
> - case V4L2_MBUS_FMT_SGRBG10_1X10:
> + case MEDIA_BUS_FMT_SGRBG10_1X10:
> isif_ccolp = ISIF_CCOLP_CP0_F0_GR |
> ISIF_CCOLP_CP1_F0_R |
> ISIF_CCOLP_CP2_F0_B |
> ISIF_CCOLP_CP3_F0_GB;
> goto cont_raw;
> - case V4L2_MBUS_FMT_SRGGB10_1X10:
> + case MEDIA_BUS_FMT_SRGGB10_1X10:
> isif_ccolp = ISIF_CCOLP_CP0_F0_R |
> ISIF_CCOLP_CP1_F0_GR |
> ISIF_CCOLP_CP2_F0_GB |
> ISIF_CCOLP_CP3_F0_B;
> goto cont_raw;
> - case V4L2_MBUS_FMT_SBGGR10_1X10:
> + case MEDIA_BUS_FMT_SBGGR10_1X10:
> isif_ccolp = ISIF_CCOLP_CP0_F0_B |
> ISIF_CCOLP_CP1_F0_GB |
> ISIF_CCOLP_CP2_F0_GR |
> ISIF_CCOLP_CP3_F0_R;
> goto cont_raw;
> - case V4L2_MBUS_FMT_SGBRG10_1X10:
> + case MEDIA_BUS_FMT_SGBRG10_1X10:
> isif_ccolp = ISIF_CCOLP_CP0_F0_GB |
> ISIF_CCOLP_CP1_F0_B |
> ISIF_CCOLP_CP2_F0_R |
> @@ -415,7 +415,7 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif,
>
> /* If not found, use SGRBG10 as default */
> if (i >= ARRAY_SIZE(ipipeif_fmts))
> - fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
>
> /* Clamp the input size. */
> fmt->width = clamp_t(u32, width, 1, 8192);
> @@ -625,7 +625,7 @@ static int ipipeif_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = IPIPEIF_PAD_SINK;
> format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
> - format.format.code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
> format.format.width = 4096;
> format.format.height = 4096;
> ipipeif_set_format(sd, fh, &format);
> diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c
> index a21e356..88522a8 100644
> --- a/drivers/staging/media/omap4iss/iss_resizer.c
> +++ b/drivers/staging/media/omap4iss/iss_resizer.c
> @@ -24,8 +24,8 @@
> #include "iss_resizer.h"
>
> static const unsigned int resizer_fmts[] = {
> - V4L2_MBUS_FMT_UYVY8_1X16,
> - V4L2_MBUS_FMT_YUYV8_1X16,
> + MEDIA_BUS_FMT_UYVY8_1X16,
> + MEDIA_BUS_FMT_YUYV8_1X16,
> };
>
> /*
> @@ -156,8 +156,8 @@ static void resizer_set_outaddr(struct iss_resizer_device *resizer, u32 addr)
> addr & 0xffff);
>
> /* Program UV buffer address... Hardcoded to be contiguous! */
> - if ((informat->code == V4L2_MBUS_FMT_UYVY8_1X16) &&
> - (outformat->code == V4L2_MBUS_FMT_YUYV8_1_5X8)) {
> + if ((informat->code == MEDIA_BUS_FMT_UYVY8_1X16) &&
> + (outformat->code == MEDIA_BUS_FMT_YUYV8_1_5X8)) {
> u32 c_addr = addr + (resizer->video_out.bpl_value *
> (outformat->height - 1));
>
> @@ -242,8 +242,8 @@ static void resizer_configure(struct iss_resizer_device *resizer)
> resizer->video_out.bpl_value);
>
> /* UYVY -> NV12 conversion */
> - if ((informat->code == V4L2_MBUS_FMT_UYVY8_1X16) &&
> - (outformat->code == V4L2_MBUS_FMT_YUYV8_1_5X8)) {
> + if ((informat->code == MEDIA_BUS_FMT_UYVY8_1X16) &&
> + (outformat->code == MEDIA_BUS_FMT_YUYV8_1_5X8)) {
> iss_reg_write(iss, OMAP4_ISS_MEM_ISP_RESIZER, RZA_420,
> RSZ_420_CEN | RSZ_420_YEN);
>
> @@ -457,7 +457,7 @@ resizer_try_format(struct iss_resizer_device *resizer,
> struct v4l2_mbus_framefmt *fmt,
> enum v4l2_subdev_format_whence which)
> {
> - enum v4l2_mbus_pixelcode pixelcode;
> + u32 pixelcode;
> struct v4l2_mbus_framefmt *format;
> unsigned int width = fmt->width;
> unsigned int height = fmt->height;
> @@ -472,7 +472,7 @@ resizer_try_format(struct iss_resizer_device *resizer,
>
> /* If not found, use UYVY as default */
> if (i >= ARRAY_SIZE(resizer_fmts))
> - fmt->code = V4L2_MBUS_FMT_UYVY8_1X16;
> + fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
>
> /* Clamp the input size. */
> fmt->width = clamp_t(u32, width, 1, 8192);
> @@ -485,8 +485,8 @@ resizer_try_format(struct iss_resizer_device *resizer,
> which);
> memcpy(fmt, format, sizeof(*fmt));
>
> - if ((pixelcode == V4L2_MBUS_FMT_YUYV8_1_5X8) &&
> - (fmt->code == V4L2_MBUS_FMT_UYVY8_1X16))
> + if ((pixelcode == MEDIA_BUS_FMT_YUYV8_1_5X8) &&
> + (fmt->code == MEDIA_BUS_FMT_UYVY8_1X16))
> fmt->code = pixelcode;
>
> /* The data formatter truncates the number of horizontal output
> @@ -537,9 +537,9 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
> }
>
> switch (format->code) {
> - case V4L2_MBUS_FMT_UYVY8_1X16:
> + case MEDIA_BUS_FMT_UYVY8_1X16:
> if (code->index == 1)
> - code->code = V4L2_MBUS_FMT_YUYV8_1_5X8;
> + code->code = MEDIA_BUS_FMT_YUYV8_1_5X8;
> else
> return -EINVAL;
> break;
> @@ -680,7 +680,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
> memset(&format, 0, sizeof(format));
> format.pad = RESIZER_PAD_SINK;
> format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
> - format.format.code = V4L2_MBUS_FMT_UYVY8_1X16;
> + format.format.code = MEDIA_BUS_FMT_UYVY8_1X16;
> format.format.width = 4096;
> format.format.height = 4096;
> resizer_set_format(sd, fh, &format);
> diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
> index 5d62503..cdee596 100644
> --- a/drivers/staging/media/omap4iss/iss_video.c
> +++ b/drivers/staging/media/omap4iss/iss_video.c
> @@ -34,67 +34,67 @@ MODULE_PARM_DESC(debug, "activates debug info");
> */
>
> static struct iss_format_info formats[] = {
> - { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
> - V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
> + { MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8,
> + MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8,
> V4L2_PIX_FMT_GREY, 8, "Greyscale 8 bpp", },
> - { V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y10_1X10,
> - V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y8_1X8,
> + { MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y10_1X10,
> + MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y8_1X8,
> V4L2_PIX_FMT_Y10, 10, "Greyscale 10 bpp", },
> - { V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y10_1X10,
> - V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y8_1X8,
> + { MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y10_1X10,
> + MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y8_1X8,
> V4L2_PIX_FMT_Y12, 12, "Greyscale 12 bpp", },
> - { V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8,
> - V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8,
> + { MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8,
> + MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8,
> V4L2_PIX_FMT_SBGGR8, 8, "BGGR Bayer 8 bpp", },
> - { V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8,
> - V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8,
> + { MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8,
> + MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8,
> V4L2_PIX_FMT_SGBRG8, 8, "GBRG Bayer 8 bpp", },
> - { V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8,
> - V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8,
> + { MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8,
> + MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8,
> V4L2_PIX_FMT_SGRBG8, 8, "GRBG Bayer 8 bpp", },
> - { V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
> - V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
> + { MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8,
> + MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8,
> V4L2_PIX_FMT_SRGGB8, 8, "RGGB Bayer 8 bpp", },
> - { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
> - V4L2_MBUS_FMT_SGRBG10_1X10, 0,
> + { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
> + MEDIA_BUS_FMT_SGRBG10_1X10, 0,
> V4L2_PIX_FMT_SGRBG10DPCM8, 8, "GRBG Bayer 10 bpp DPCM8", },
> - { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10,
> - V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR8_1X8,
> + { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10,
> + MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR8_1X8,
> V4L2_PIX_FMT_SBGGR10, 10, "BGGR Bayer 10 bpp", },
> - { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10,
> - V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG8_1X8,
> + { MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10,
> + MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG8_1X8,
> V4L2_PIX_FMT_SGBRG10, 10, "GBRG Bayer 10 bpp", },
> - { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10,
> - V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG8_1X8,
> + { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG10_1X10,
> + MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG8_1X8,
> V4L2_PIX_FMT_SGRBG10, 10, "GRBG Bayer 10 bpp", },
> - { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10,
> - V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB8_1X8,
> + { MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10,
> + MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB8_1X8,
> V4L2_PIX_FMT_SRGGB10, 10, "RGGB Bayer 10 bpp", },
> - { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10,
> - V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR8_1X8,
> + { MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR10_1X10,
> + MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR8_1X8,
> V4L2_PIX_FMT_SBGGR12, 12, "BGGR Bayer 12 bpp", },
> - { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10,
> - V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG8_1X8,
> + { MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG10_1X10,
> + MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG8_1X8,
> V4L2_PIX_FMT_SGBRG12, 12, "GBRG Bayer 12 bpp", },
> - { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10,
> - V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG8_1X8,
> + { MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG10_1X10,
> + MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG8_1X8,
> V4L2_PIX_FMT_SGRBG12, 12, "GRBG Bayer 12 bpp", },
> - { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10,
> - V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB8_1X8,
> + { MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB10_1X10,
> + MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB8_1X8,
> V4L2_PIX_FMT_SRGGB12, 12, "RGGB Bayer 12 bpp", },
> - { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16,
> - V4L2_MBUS_FMT_UYVY8_1X16, 0,
> + { MEDIA_BUS_FMT_UYVY8_1X16, MEDIA_BUS_FMT_UYVY8_1X16,
> + MEDIA_BUS_FMT_UYVY8_1X16, 0,
> V4L2_PIX_FMT_UYVY, 16, "YUV 4:2:2 (UYVY)", },
> - { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16,
> - V4L2_MBUS_FMT_YUYV8_1X16, 0,
> + { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YUYV8_1X16,
> + MEDIA_BUS_FMT_YUYV8_1X16, 0,
> V4L2_PIX_FMT_YUYV, 16, "YUV 4:2:2 (YUYV)", },
> - { V4L2_MBUS_FMT_YUYV8_1_5X8, V4L2_MBUS_FMT_YUYV8_1_5X8,
> - V4L2_MBUS_FMT_YUYV8_1_5X8, 0,
> + { MEDIA_BUS_FMT_YUYV8_1_5X8, MEDIA_BUS_FMT_YUYV8_1_5X8,
> + MEDIA_BUS_FMT_YUYV8_1_5X8, 0,
> V4L2_PIX_FMT_NV12, 8, "YUV 4:2:0 (NV12)", },
> };
>
> const struct iss_format_info *
> -omap4iss_video_format_info(enum v4l2_mbus_pixelcode code)
> +omap4iss_video_format_info(u32 code)
> {
> unsigned int i;
>
> diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h
> index 9dccdb1..f11fce2 100644
> --- a/drivers/staging/media/omap4iss/iss_video.h
> +++ b/drivers/staging/media/omap4iss/iss_video.h
> @@ -43,10 +43,10 @@ struct v4l2_pix_format;
> * @description: Human-readable format description
> */
> struct iss_format_info {
> - enum v4l2_mbus_pixelcode code;
> - enum v4l2_mbus_pixelcode truncated;
> - enum v4l2_mbus_pixelcode uncompressed;
> - enum v4l2_mbus_pixelcode flavor;
> + u32 code;
> + u32 truncated;
> + u32 uncompressed;
> + u32 flavor;
> u32 pixelformat;
> unsigned int bpp;
> const char *description;
> @@ -199,6 +199,6 @@ void omap4iss_video_cancel_stream(struct iss_video *video);
> struct media_pad *omap4iss_video_remote_pad(struct iss_video *video);
>
> const struct iss_format_info *
> -omap4iss_video_format_info(enum v4l2_mbus_pixelcode code);
> +omap4iss_video_format_info(u32 code);
>
> #endif /* OMAP4_ISS_VIDEO_H */
> --
> 1.9.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply
* Re: [PATCH v3 06/10] [media] platform: Make use of media_bus_format enum
From: Prabhakar Lad @ 2014-11-08 9:18 UTC (permalink / raw)
To: Boris Brezillon, Sekhar Nori
Cc: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media, Sakari Ailus, LAK, linux-api, OSUOSL Drivers, LKML,
LDOC, Guennadi Liakhovetski
In-Reply-To: <1415369269-5064-7-git-send-email-boris.brezillon@free-electrons.com>
Hi,
Thanks for the patch,
On Fri, Nov 7, 2014 at 2:07 PM, Boris Brezillon
<boris.brezillon@free-electrons.com> 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 values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.
>
> Reference new definitions in all platform drivers.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> 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 +-
@Sekhar can you ack for the machine changes for davinci ?
[Snip]
> drivers/media/platform/davinci/vpbe.c | 2 +-
> drivers/media/platform/davinci/vpfe_capture.c | 4 +-
[snip]
> include/media/davinci/vpbe.h | 2 +-
> include/media/davinci/vpbe_venc.h | 5 +-
For all the above.
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Thanks,
--Prabhakar Lad
^ permalink raw reply
* Re: [PATCH v3 04/10] [media] i2c: Make use of media_bus_format enum
From: Prabhakar Lad @ 2014-11-08 9:23 UTC (permalink / raw)
To: Boris Brezillon
Cc: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media, Sakari Ailus, OSUOSL Drivers, LDOC, linux-api, LKML,
Guennadi Liakhovetski, LAK
In-Reply-To: <1415369269-5064-5-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
On Fri, Nov 7, 2014 at 2:07 PM, Boris Brezillon
<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:
> 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.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
[Snip]
> drivers/media/i2c/mt9p031.c | 8 ++--
[Snip]
> drivers/media/i2c/tvp514x.c | 12 +++---
> drivers/media/i2c/tvp7002.c | 10 ++---
For all the above,
Acked-by: Lad, Prabhakar <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Thanks,
--Prabhakar Lad
> 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 *to_adv7175(struct v4l2_subdev *sd)
>
> static char *inputs[] = { "pass_through", "play_back", "color_bar" };
>
> -static enum v4l2_mbus_pixelcode adv7175_codes[] = {
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_UYVY8_1X16,
> +static u32 adv7175_codes[] = {
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_UYVY8_1X16,
> };
>
> /* ----------------------------------------------------------------------- */
> @@ -301,7 +301,7 @@ static int adv7175_s_routing(struct v4l2_subdev *sd,
> }
>
> static int adv7175_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(adv7175_codes))
> return -EINVAL;
> @@ -316,9 +316,9 @@ static int adv7175_g_fmt(struct v4l2_subdev *sd,
> u8 val = adv7175_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;
> @@ -335,11 +335,11 @@ static int adv7175_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/adv7180.c b/drivers/media/i2c/adv7180.c
> index 821178d..bffe6eb 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -422,12 +422,12 @@ static void adv7180_exit_controls(struct adv7180_state *state)
> }
>
> static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index > 0)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_YUYV8_2X8;
> + *code = MEDIA_BUS_FMT_YUYV8_2X8;
>
> return 0;
> }
> @@ -437,7 +437,7 @@ static int adv7180_mbus_fmt(struct v4l2_subdev *sd,
> {
> struct adv7180_state *state = to_state(sd);
>
> - fmt->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + fmt->code = MEDIA_BUS_FMT_YUYV8_2X8;
> fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
> fmt->field = V4L2_FIELD_INTERLACED;
> fmt->width = 720;
> diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
> index df461b0..28940cc 100644
> --- a/drivers/media/i2c/adv7183.c
> +++ b/drivers/media/i2c/adv7183.c
> @@ -421,12 +421,12 @@ static int adv7183_g_input_status(struct v4l2_subdev *sd, u32 *status)
> }
>
> static int adv7183_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index > 0)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_UYVY8_2X8;
> + *code = MEDIA_BUS_FMT_UYVY8_2X8;
> return 0;
> }
>
> @@ -435,7 +435,7 @@ static int adv7183_try_mbus_fmt(struct v4l2_subdev *sd,
> {
> struct adv7183 *decoder = to_adv7183(sd);
>
> - fmt->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
> fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
> if (decoder->std & V4L2_STD_525_60) {
> fmt->field = V4L2_FIELD_SEQ_TB;
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 47795ff..6cccaca 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -88,7 +88,7 @@ struct adv7604_reg_seq {
> };
>
> struct adv7604_format_info {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> u8 op_ch_sel;
> bool rgb_out;
> bool swap_cb_cr;
> @@ -749,77 +749,77 @@ static void adv7604_write_reg_seq(struct v4l2_subdev *sd,
> */
>
> static const struct adv7604_format_info adv7604_formats[] = {
> - { V4L2_MBUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false,
> + { MEDIA_BUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false,
> ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YUYV10_2X10, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV10_2X10, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT },
> - { V4L2_MBUS_FMT_YVYU10_2X10, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU10_2X10, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT },
> - { V4L2_MBUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false,
> + { MEDIA_BUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true,
> + { MEDIA_BUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_UYVY10_1X20, ADV7604_OP_CH_SEL_RBG, false, false,
> + { MEDIA_BUS_FMT_UYVY10_1X20, ADV7604_OP_CH_SEL_RBG, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT },
> - { V4L2_MBUS_FMT_VYUY10_1X20, ADV7604_OP_CH_SEL_RBG, false, true,
> + { MEDIA_BUS_FMT_VYUY10_1X20, ADV7604_OP_CH_SEL_RBG, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT },
> - { V4L2_MBUS_FMT_YUYV10_1X20, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV10_1X20, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT },
> - { V4L2_MBUS_FMT_YVYU10_1X20, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU10_1X20, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT },
> - { V4L2_MBUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false,
> + { MEDIA_BUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true,
> + { MEDIA_BUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> };
>
> static const struct adv7604_format_info adv7611_formats[] = {
> - { V4L2_MBUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false,
> + { MEDIA_BUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false,
> ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false,
> + { MEDIA_BUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true,
> + { MEDIA_BUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT },
> - { V4L2_MBUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false,
> + { MEDIA_BUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true,
> + { MEDIA_BUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false,
> + { MEDIA_BUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> - { V4L2_MBUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true,
> + { MEDIA_BUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true,
> ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT },
> };
>
> static const struct adv7604_format_info *
> -adv7604_format_info(struct adv7604_state *state, enum v4l2_mbus_pixelcode code)
> +adv7604_format_info(struct adv7604_state *state, u32 code)
> {
> unsigned int i;
>
> @@ -1917,7 +1917,7 @@ static int adv7604_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
>
> info = adv7604_format_info(state, format->format.code);
> if (info == NULL)
> - info = adv7604_format_info(state, V4L2_MBUS_FMT_YUYV8_2X8);
> + info = adv7604_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8);
>
> adv7604_fill_format(state, &format->format);
> format->format.code = info->code;
> @@ -2807,7 +2807,7 @@ static int adv7604_probe(struct i2c_client *client,
> }
>
> state->timings = cea640x480;
> - state->format = adv7604_format_info(state, V4L2_MBUS_FMT_YUYV8_2X8);
> + state->format = adv7604_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8);
>
> sd = &state->sd;
> v4l2_i2c_subdev_init(sd, client, &adv7604_ops);
> diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
> index 48b628b..d237250 100644
> --- a/drivers/media/i2c/adv7842.c
> +++ b/drivers/media/i2c/adv7842.c
> @@ -1877,12 +1877,12 @@ static int adv7842_s_routing(struct v4l2_subdev *sd,
> }
>
> static int adv7842_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index)
> return -EINVAL;
> /* Good enough for now */
> - *code = V4L2_MBUS_FMT_FIXED;
> + *code = MEDIA_BUS_FMT_FIXED;
> return 0;
> }
>
> @@ -1893,7 +1893,7 @@ static int adv7842_g_mbus_fmt(struct v4l2_subdev *sd,
>
> fmt->width = state->timings.bt.width;
> fmt->height = state->timings.bt.height;
> - fmt->code = V4L2_MBUS_FMT_FIXED;
> + fmt->code = MEDIA_BUS_FMT_FIXED;
> fmt->field = V4L2_FIELD_NONE;
>
> if (state->mode == ADV7842_MODE_SDP) {
> diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c
> index c14e667..69aeaf3 100644
> --- a/drivers/media/i2c/ak881x.c
> +++ b/drivers/media/i2c/ak881x.c
> @@ -102,7 +102,7 @@ static int ak881x_try_g_mbus_fmt(struct v4l2_subdev *sd,
> v4l_bound_align_image(&mf->width, 0, 720, 2,
> &mf->height, 0, ak881x->lines, 1, 0);
> mf->field = V4L2_FIELD_INTERLACED;
> - mf->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + mf->code = MEDIA_BUS_FMT_YUYV8_2X8;
> mf->colorspace = V4L2_COLORSPACE_SMPTE170M;
>
> return 0;
> @@ -112,19 +112,19 @@ static int ak881x_s_mbus_fmt(struct v4l2_subdev *sd,
> struct v4l2_mbus_framefmt *mf)
> {
> if (mf->field != V4L2_FIELD_INTERLACED ||
> - mf->code != V4L2_MBUS_FMT_YUYV8_2X8)
> + mf->code != MEDIA_BUS_FMT_YUYV8_2X8)
> return -EINVAL;
>
> return ak881x_try_g_mbus_fmt(sd, mf);
> }
>
> static int ak881x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_YUYV8_2X8;
> + *code = MEDIA_BUS_FMT_YUYV8_2X8;
> return 0;
> }
>
> diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
> index e453a3f..f29a165 100644
> --- a/drivers/media/i2c/cx25840/cx25840-core.c
> +++ b/drivers/media/i2c/cx25840/cx25840-core.c
> @@ -1373,7 +1373,7 @@ static int cx25840_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/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
> index 8d870b7..2820f7c 100644
> --- a/drivers/media/i2c/m5mols/m5mols_core.c
> +++ b/drivers/media/i2c/m5mols/m5mols_core.c
> @@ -57,14 +57,14 @@ static struct v4l2_mbus_framefmt m5mols_default_ffmt[M5MOLS_RESTYPE_MAX] = {
> [M5MOLS_RESTYPE_MONITOR] = {
> .width = 1920,
> .height = 1080,
> - .code = V4L2_MBUS_FMT_VYUY8_2X8,
> + .code = MEDIA_BUS_FMT_VYUY8_2X8,
> .field = V4L2_FIELD_NONE,
> .colorspace = V4L2_COLORSPACE_JPEG,
> },
> [M5MOLS_RESTYPE_CAPTURE] = {
> .width = 1920,
> .height = 1080,
> - .code = V4L2_MBUS_FMT_JPEG_1X8,
> + .code = MEDIA_BUS_FMT_JPEG_1X8,
> .field = V4L2_FIELD_NONE,
> .colorspace = V4L2_COLORSPACE_JPEG,
> },
> @@ -479,7 +479,7 @@ static int m5mols_get_version(struct v4l2_subdev *sd)
> * __find_restype - Lookup M-5MOLS resolution type according to pixel code
> * @code: pixel code
> */
> -static enum m5mols_restype __find_restype(enum v4l2_mbus_pixelcode code)
> +static enum m5mols_restype __find_restype(u32 code)
> {
> enum m5mols_restype type = M5MOLS_RESTYPE_MONITOR;
>
> diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
> index 2cace73..d730786 100644
> --- a/drivers/media/i2c/ml86v7667.c
> +++ b/drivers/media/i2c/ml86v7667.c
> @@ -192,12 +192,12 @@ static int ml86v7667_g_input_status(struct v4l2_subdev *sd, u32 *status)
> }
>
> static int ml86v7667_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index > 0)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_YUYV8_2X8;
> + *code = MEDIA_BUS_FMT_YUYV8_2X8;
>
> return 0;
> }
> @@ -207,7 +207,7 @@ static int ml86v7667_mbus_fmt(struct v4l2_subdev *sd,
> {
> struct ml86v7667_priv *priv = to_ml86v7667(sd);
>
> - fmt->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + fmt->code = MEDIA_BUS_FMT_YUYV8_2X8;
> fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
> /* The top field is always transferred first by the chip */
> fmt->field = V4L2_FIELD_INTERLACED_TB;
> diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
> index 85ec3ba..45b3fca 100644
> --- a/drivers/media/i2c/mt9m032.c
> +++ b/drivers/media/i2c/mt9m032.c
> @@ -323,7 +323,7 @@ static int mt9m032_enum_mbus_code(struct v4l2_subdev *subdev,
> if (code->index != 0)
> return -EINVAL;
>
> - code->code = V4L2_MBUS_FMT_Y8_1X8;
> + code->code = MEDIA_BUS_FMT_Y8_1X8;
> return 0;
> }
>
> @@ -331,7 +331,7 @@ static int mt9m032_enum_frame_size(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> - if (fse->index != 0 || fse->code != V4L2_MBUS_FMT_Y8_1X8)
> + if (fse->index != 0 || fse->code != MEDIA_BUS_FMT_Y8_1X8)
> return -EINVAL;
>
> fse->min_width = MT9M032_COLUMN_SIZE_DEF;
> @@ -759,7 +759,7 @@ static int mt9m032_probe(struct i2c_client *client,
>
> sensor->format.width = sensor->crop.width;
> sensor->format.height = sensor->crop.height;
> - sensor->format.code = V4L2_MBUS_FMT_Y8_1X8;
> + sensor->format.code = MEDIA_BUS_FMT_Y8_1X8;
> sensor->format.field = V4L2_FIELD_NONE;
> sensor->format.colorspace = V4L2_COLORSPACE_SRGB;
>
> diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
> index e18797f..edb76bd 100644
> --- a/drivers/media/i2c/mt9p031.c
> +++ b/drivers/media/i2c/mt9p031.c
> @@ -950,9 +950,9 @@ static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
> format = v4l2_subdev_get_try_format(fh, 0);
>
> if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
> - format->code = V4L2_MBUS_FMT_Y12_1X12;
> + format->code = MEDIA_BUS_FMT_Y12_1X12;
> else
> - format->code = V4L2_MBUS_FMT_SGRBG12_1X12;
> + format->code = MEDIA_BUS_FMT_SGRBG12_1X12;
>
> format->width = MT9P031_WINDOW_WIDTH_DEF;
> format->height = MT9P031_WINDOW_HEIGHT_DEF;
> @@ -1120,9 +1120,9 @@ static int mt9p031_probe(struct i2c_client *client,
> mt9p031->crop.top = MT9P031_ROW_START_DEF;
>
> if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
> - mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12;
> + mt9p031->format.code = MEDIA_BUS_FMT_Y12_1X12;
> else
> - mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
> + mt9p031->format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
>
> mt9p031->format.width = MT9P031_WINDOW_WIDTH_DEF;
> mt9p031->format.height = MT9P031_WINDOW_HEIGHT_DEF;
> diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
> index 422e068..d9e9889 100644
> --- a/drivers/media/i2c/mt9t001.c
> +++ b/drivers/media/i2c/mt9t001.c
> @@ -333,7 +333,7 @@ static int mt9t001_enum_mbus_code(struct v4l2_subdev *subdev,
> if (code->index > 0)
> return -EINVAL;
>
> - code->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
> return 0;
> }
>
> @@ -341,7 +341,7 @@ static int mt9t001_enum_frame_size(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> - if (fse->index >= 8 || fse->code != V4L2_MBUS_FMT_SGRBG10_1X10)
> + if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
> return -EINVAL;
>
> fse->min_width = (MT9T001_WINDOW_WIDTH_DEF + 1) / fse->index;
> @@ -792,7 +792,7 @@ static int mt9t001_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
> crop->height = MT9T001_WINDOW_HEIGHT_DEF + 1;
>
> format = v4l2_subdev_get_try_format(fh, 0);
> - format->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + format->code = MEDIA_BUS_FMT_SGRBG10_1X10;
> format->width = MT9T001_WINDOW_WIDTH_DEF + 1;
> format->height = MT9T001_WINDOW_HEIGHT_DEF + 1;
> format->field = V4L2_FIELD_NONE;
> @@ -917,7 +917,7 @@ static int mt9t001_probe(struct i2c_client *client,
> mt9t001->crop.width = MT9T001_WINDOW_WIDTH_DEF + 1;
> mt9t001->crop.height = MT9T001_WINDOW_HEIGHT_DEF + 1;
>
> - mt9t001->format.code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + mt9t001->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
> mt9t001->format.width = MT9T001_WINDOW_WIDTH_DEF + 1;
> mt9t001->format.height = MT9T001_WINDOW_HEIGHT_DEF + 1;
> mt9t001->format.field = V4L2_FIELD_NONE;
> diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
> index 47e4753..a10f7f8 100644
> --- a/drivers/media/i2c/mt9v011.c
> +++ b/drivers/media/i2c/mt9v011.c
> @@ -325,18 +325,18 @@ static int mt9v011_reset(struct v4l2_subdev *sd, u32 val)
> }
>
> static int mt9v011_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index > 0)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_SGRBG8_1X8;
> + *code = MEDIA_BUS_FMT_SGRBG8_1X8;
> return 0;
> }
>
> static int mt9v011_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
> {
> - if (fmt->code != V4L2_MBUS_FMT_SGRBG8_1X8)
> + if (fmt->code != MEDIA_BUS_FMT_SGRBG8_1X8)
> return -EINVAL;
>
> v4l_bound_align_image(&fmt->width, 48, 639, 1,
> diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
> index d044bce..93687c1 100644
> --- a/drivers/media/i2c/mt9v032.c
> +++ b/drivers/media/i2c/mt9v032.c
> @@ -454,7 +454,7 @@ static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev,
> if (code->index > 0)
> return -EINVAL;
>
> - code->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
> return 0;
> }
>
> @@ -462,7 +462,7 @@ static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> - if (fse->index >= 3 || fse->code != V4L2_MBUS_FMT_SGRBG10_1X10)
> + if (fse->index >= 3 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
> return -EINVAL;
>
> fse->min_width = MT9V032_WINDOW_WIDTH_DEF / (1 << fse->index);
> @@ -814,9 +814,9 @@ static int mt9v032_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
> format = v4l2_subdev_get_try_format(fh, 0);
>
> if (mt9v032->model->color)
> - format->code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + format->code = MEDIA_BUS_FMT_SGRBG10_1X10;
> else
> - format->code = V4L2_MBUS_FMT_Y10_1X10;
> + format->code = MEDIA_BUS_FMT_Y10_1X10;
>
> format->width = MT9V032_WINDOW_WIDTH_DEF;
> format->height = MT9V032_WINDOW_HEIGHT_DEF;
> @@ -966,9 +966,9 @@ static int mt9v032_probe(struct i2c_client *client,
> mt9v032->crop.height = MT9V032_WINDOW_HEIGHT_DEF;
>
> if (mt9v032->model->color)
> - mt9v032->format.code = V4L2_MBUS_FMT_SGRBG10_1X10;
> + mt9v032->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
> else
> - mt9v032->format.code = V4L2_MBUS_FMT_Y10_1X10;
> + mt9v032->format.code = MEDIA_BUS_FMT_Y10_1X10;
>
> mt9v032->format.width = MT9V032_WINDOW_WIDTH_DEF;
> mt9v032->format.height = MT9V032_WINDOW_HEIGHT_DEF;
> diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
> index 7eae487..00c7b26 100644
> --- a/drivers/media/i2c/noon010pc30.c
> +++ b/drivers/media/i2c/noon010pc30.c
> @@ -112,7 +112,7 @@ MODULE_PARM_DESC(debug, "Enable module debug trace. Set to 1 to enable.");
> #define REG_TERM 0xFFFF
>
> struct noon010_format {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> u16 ispctl1_reg;
> };
> @@ -175,23 +175,23 @@ static const struct noon010_frmsize noon010_sizes[] = {
> /* Supported pixel formats. */
> static const struct noon010_format noon010_formats[] = {
> {
> - .code = V4L2_MBUS_FMT_YUYV8_2X8,
> + .code = MEDIA_BUS_FMT_YUYV8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x03,
> }, {
> - .code = V4L2_MBUS_FMT_YVYU8_2X8,
> + .code = MEDIA_BUS_FMT_YVYU8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x02,
> }, {
> - .code = V4L2_MBUS_FMT_VYUY8_2X8,
> + .code = MEDIA_BUS_FMT_VYUY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0,
> }, {
> - .code = V4L2_MBUS_FMT_UYVY8_2X8,
> + .code = MEDIA_BUS_FMT_UYVY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x01,
> }, {
> - .code = V4L2_MBUS_FMT_RGB565_2X8_BE,
> + .code = MEDIA_BUS_FMT_RGB565_2X8_BE,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x40,
> },
> diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
> index dd3db24..957927f 100644
> --- a/drivers/media/i2c/ov7670.c
> +++ b/drivers/media/i2c/ov7670.c
> @@ -632,31 +632,31 @@ static int ov7670_detect(struct v4l2_subdev *sd)
> * The magic matrix numbers come from OmniVision.
> */
> static struct ov7670_format_struct {
> - enum v4l2_mbus_pixelcode mbus_code;
> + u32 mbus_code;
> enum v4l2_colorspace colorspace;
> struct regval_list *regs;
> int cmatrix[CMATRIX_LEN];
> } ov7670_formats[] = {
> {
> - .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8,
> + .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .regs = ov7670_fmt_yuv422,
> .cmatrix = { 128, -128, 0, -34, -94, 128 },
> },
> {
> - .mbus_code = V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE,
> + .mbus_code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .regs = ov7670_fmt_rgb444,
> .cmatrix = { 179, -179, 0, -61, -176, 228 },
> },
> {
> - .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE,
> + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .regs = ov7670_fmt_rgb565,
> .cmatrix = { 179, -179, 0, -61, -176, 228 },
> },
> {
> - .mbus_code = V4L2_MBUS_FMT_SBGGR8_1X8,
> + .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .regs = ov7670_fmt_raw,
> .cmatrix = { 0, 0, 0, 0, 0, 0 },
> @@ -772,7 +772,7 @@ static void ov7675_get_framerate(struct v4l2_subdev *sd,
> pll_factor = PLL_FACTOR;
>
> clkrc++;
> - if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8)
> + if (info->fmt->mbus_code == MEDIA_BUS_FMT_SBGGR8_1X8)
> clkrc = (clkrc >> 1);
>
> tpf->numerator = 1;
> @@ -810,7 +810,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd,
> } else {
> clkrc = (5 * pll_factor * info->clock_speed * tpf->numerator) /
> (4 * tpf->denominator);
> - if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8)
> + if (info->fmt->mbus_code == MEDIA_BUS_FMT_SBGGR8_1X8)
> clkrc = (clkrc << 1);
> clkrc--;
> }
> @@ -900,7 +900,7 @@ static int ov7670_set_hw(struct v4l2_subdev *sd, int hstart, int hstop,
>
>
> static int ov7670_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= N_OV7670_FMTS)
> return -EINVAL;
> diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
> index 4da90c6..2246bd5 100644
> --- a/drivers/media/i2c/ov9650.c
> +++ b/drivers/media/i2c/ov9650.c
> @@ -384,17 +384,17 @@ static const struct ov965x_framesize ov965x_framesizes[] = {
> };
>
> struct ov965x_pixfmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> u32 colorspace;
> /* REG_TSLB value, only bits [3:2] may be set. */
> u8 tslb_reg;
> };
>
> static const struct ov965x_pixfmt ov965x_formats[] = {
> - { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 0x00},
> - { V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG, 0x04},
> - { V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG, 0x0c},
> - { V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 0x08},
> + { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 0x00},
> + { MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG, 0x04},
> + { MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG, 0x0c},
> + { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 0x08},
> };
>
> /*
> diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h
> index 9656b67..13aed59 100644
> --- a/drivers/media/i2c/s5c73m3/s5c73m3.h
> +++ b/drivers/media/i2c/s5c73m3/s5c73m3.h
> @@ -27,8 +27,8 @@
>
> #define DRIVER_NAME "S5C73M3"
>
> -#define S5C73M3_ISP_FMT V4L2_MBUS_FMT_VYUY8_2X8
> -#define S5C73M3_JPEG_FMT V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8
> +#define S5C73M3_ISP_FMT MEDIA_BUS_FMT_VYUY8_2X8
> +#define S5C73M3_JPEG_FMT MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8
>
> /* Subdevs pad index definitions */
> enum s5c73m3_pads {
> @@ -402,7 +402,7 @@ struct s5c73m3 {
>
> const struct s5c73m3_frame_size *sensor_pix_size[2];
> const struct s5c73m3_frame_size *oif_pix_size[2];
> - enum v4l2_mbus_pixelcode mbus_code;
> + u32 mbus_code;
>
> const struct s5c73m3_interval *fiv;
>
> diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
> index 1fcc76f..d1c50c9 100644
> --- a/drivers/media/i2c/s5k4ecgx.c
> +++ b/drivers/media/i2c/s5k4ecgx.c
> @@ -151,7 +151,7 @@ static const struct s5k4ecgx_frmsize s5k4ecgx_prev_sizes[] = {
> #define S5K4ECGX_NUM_PREV ARRAY_SIZE(s5k4ecgx_prev_sizes)
>
> struct s5k4ecgx_pixfmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> u32 colorspace;
> /* REG_TC_PCFG_Format register value */
> u16 reg_p_format;
> @@ -159,7 +159,7 @@ struct s5k4ecgx_pixfmt {
>
> /* By default value, output from sensor will be YUV422 0-255 */
> static const struct s5k4ecgx_pixfmt s5k4ecgx_formats[] = {
> - { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 },
> + { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 },
> };
>
> static const char * const s5k4ecgx_supply_names[] = {
> diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
> index 0e461a6..60a74d8 100644
> --- a/drivers/media/i2c/s5k5baf.c
> +++ b/drivers/media/i2c/s5k5baf.c
> @@ -248,7 +248,7 @@ enum s5k5baf_gpio_id {
> #define NUM_ISP_PADS 2
>
> struct s5k5baf_pixfmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> u32 colorspace;
> /* REG_P_FMT(x) register value */
> u16 reg_p_fmt;
> @@ -331,10 +331,10 @@ struct s5k5baf {
> };
>
> static const struct s5k5baf_pixfmt s5k5baf_formats[] = {
> - { V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 5 },
> + { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 5 },
> /* range 16-240 */
> - { V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_REC709, 6 },
> - { V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 },
> + { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_REC709, 6 },
> + { MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 },
> };
>
> static struct v4l2_rect s5k5baf_cis_rect = {
> @@ -1206,7 +1206,7 @@ static int s5k5baf_enum_mbus_code(struct v4l2_subdev *sd,
> if (code->pad == PAD_CIS) {
> if (code->index > 0)
> return -EINVAL;
> - code->code = V4L2_MBUS_FMT_FIXED;
> + code->code = MEDIA_BUS_FMT_FIXED;
> return 0;
> }
>
> @@ -1227,7 +1227,7 @@ static int s5k5baf_enum_frame_size(struct v4l2_subdev *sd,
> return -EINVAL;
>
> if (fse->pad == PAD_CIS) {
> - fse->code = V4L2_MBUS_FMT_FIXED;
> + fse->code = MEDIA_BUS_FMT_FIXED;
> fse->min_width = S5K5BAF_CIS_WIDTH;
> fse->max_width = S5K5BAF_CIS_WIDTH;
> fse->min_height = S5K5BAF_CIS_HEIGHT;
> @@ -1252,7 +1252,7 @@ static void s5k5baf_try_cis_format(struct v4l2_mbus_framefmt *mf)
> {
> mf->width = S5K5BAF_CIS_WIDTH;
> mf->height = S5K5BAF_CIS_HEIGHT;
> - mf->code = V4L2_MBUS_FMT_FIXED;
> + mf->code = MEDIA_BUS_FMT_FIXED;
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> mf->field = V4L2_FIELD_NONE;
> }
> diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
> index c11a408..91b841a 100644
> --- a/drivers/media/i2c/s5k6a3.c
> +++ b/drivers/media/i2c/s5k6a3.c
> @@ -80,7 +80,7 @@ static inline struct s5k6a3 *sd_to_s5k6a3(struct v4l2_subdev *sd)
>
> static const struct v4l2_mbus_framefmt s5k6a3_formats[] = {
> {
> - .code = V4L2_MBUS_FMT_SGRBG10_1X10,
> + .code = MEDIA_BUS_FMT_SGRBG10_1X10,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .field = V4L2_FIELD_NONE,
> }
> diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
> index 629a5cd..2851581 100644
> --- a/drivers/media/i2c/s5k6aa.c
> +++ b/drivers/media/i2c/s5k6aa.c
> @@ -191,7 +191,7 @@ struct s5k6aa_regval {
> };
>
> struct s5k6aa_pixfmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> u32 colorspace;
> /* REG_P_FMT(x) register value */
> u16 reg_p_fmt;
> @@ -285,10 +285,10 @@ static struct s5k6aa_regval s5k6aa_analog_config[] = {
>
> /* TODO: Add RGB888 and Bayer format */
> static const struct s5k6aa_pixfmt s5k6aa_formats[] = {
> - { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 },
> + { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 },
> /* range 16-240 */
> - { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_REC709, 6 },
> - { V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 },
> + { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_REC709, 6 },
> + { MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 },
> };
>
> static const struct s5k6aa_interval s5k6aa_intervals[] = {
> diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c
> index 4024ea6..f14c0e6 100644
> --- a/drivers/media/i2c/saa6752hs.c
> +++ b/drivers/media/i2c/saa6752hs.c
> @@ -562,7 +562,7 @@ static int saa6752hs_g_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm
> h->video_format = SAA6752HS_VF_D1;
> f->width = v4l2_format_table[h->video_format].fmt.pix.width;
> f->height = v4l2_format_table[h->video_format].fmt.pix.height;
> - f->code = V4L2_MBUS_FMT_FIXED;
> + f->code = MEDIA_BUS_FMT_FIXED;
> f->field = V4L2_FIELD_INTERLACED;
> f->colorspace = V4L2_COLORSPACE_SMPTE170M;
> return 0;
> @@ -572,7 +572,7 @@ static int saa6752hs_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_frame
> {
> int dist_352, dist_480, dist_720;
>
> - f->code = V4L2_MBUS_FMT_FIXED;
> + f->code = MEDIA_BUS_FMT_FIXED;
>
> dist_352 = abs(f->width - 352);
> dist_480 = abs(f->width - 480);
> @@ -599,7 +599,7 @@ static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm
> {
> struct saa6752hs_state *h = to_state(sd);
>
> - if (f->code != V4L2_MBUS_FMT_FIXED)
> + if (f->code != MEDIA_BUS_FMT_FIXED)
> return -EINVAL;
>
> /*
> diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
> index 35a4464..7147c8b 100644
> --- a/drivers/media/i2c/saa7115.c
> +++ b/drivers/media/i2c/saa7115.c
> @@ -1172,7 +1172,7 @@ static int saa711x_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f
>
> static int saa711x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
> {
> - if (fmt->code != V4L2_MBUS_FMT_FIXED)
> + if (fmt->code != MEDIA_BUS_FMT_FIXED)
> return -EINVAL;
> fmt->field = V4L2_FIELD_INTERLACED;
> fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
> diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c
> index 6922a9f..0d0f9a9 100644
> --- a/drivers/media/i2c/saa717x.c
> +++ b/drivers/media/i2c/saa717x.c
> @@ -998,7 +998,7 @@ static int saa717x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt
>
> v4l2_dbg(1, debug, sd, "decoder set size\n");
>
> - if (fmt->code != V4L2_MBUS_FMT_FIXED)
> + if (fmt->code != MEDIA_BUS_FMT_FIXED)
> return -EINVAL;
>
> /* FIXME need better bounds checking here */
> diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
> index 932ed9b..82d2e0a 100644
> --- a/drivers/media/i2c/smiapp/smiapp-core.c
> +++ b/drivers/media/i2c/smiapp/smiapp-core.c
> @@ -333,22 +333,22 @@ static void __smiapp_update_exposure_limits(struct smiapp_sensor *sensor)
> * orders must be defined.
> */
> static const struct smiapp_csi_data_format smiapp_csi_data_formats[] = {
> - { V4L2_MBUS_FMT_SGRBG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GRBG, },
> - { V4L2_MBUS_FMT_SRGGB12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_RGGB, },
> - { V4L2_MBUS_FMT_SBGGR12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_BGGR, },
> - { V4L2_MBUS_FMT_SGBRG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GBRG, },
> - { V4L2_MBUS_FMT_SGRBG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GRBG, },
> - { V4L2_MBUS_FMT_SRGGB10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_RGGB, },
> - { V4L2_MBUS_FMT_SBGGR10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_BGGR, },
> - { V4L2_MBUS_FMT_SGBRG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GBRG, },
> - { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GRBG, },
> - { V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_RGGB, },
> - { V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_BGGR, },
> - { V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GBRG, },
> - { V4L2_MBUS_FMT_SGRBG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GRBG, },
> - { V4L2_MBUS_FMT_SRGGB8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_RGGB, },
> - { V4L2_MBUS_FMT_SBGGR8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_BGGR, },
> - { V4L2_MBUS_FMT_SGBRG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GBRG, },
> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GRBG, },
> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_RGGB, },
> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_BGGR, },
> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GBRG, },
> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GRBG, },
> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_RGGB, },
> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_BGGR, },
> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GBRG, },
> + { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GRBG, },
> + { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_RGGB, },
> + { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_BGGR, },
> + { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GBRG, },
> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GRBG, },
> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_RGGB, },
> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_BGGR, },
> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GBRG, },
> };
>
> const char *pixel_order_str[] = { "GRBG", "RGGB", "BGGR", "GBRG" };
> diff --git a/drivers/media/i2c/soc_camera/imx074.c b/drivers/media/i2c/soc_camera/imx074.c
> index 5b91593..ec89cfa 100644
> --- a/drivers/media/i2c/soc_camera/imx074.c
> +++ b/drivers/media/i2c/soc_camera/imx074.c
> @@ -71,7 +71,7 @@
>
> /* IMX074 has only one fixed colorspace per pixelcode */
> struct imx074_datafmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
> @@ -82,7 +82,7 @@ struct imx074 {
> };
>
> static const struct imx074_datafmt imx074_colour_fmts[] = {
> - {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> };
>
> static struct imx074 *to_imx074(const struct i2c_client *client)
> @@ -91,7 +91,7 @@ static struct imx074 *to_imx074(const struct i2c_client *client)
> }
>
> /* Find a data format by a pixel code in an array */
> -static const struct imx074_datafmt *imx074_find_datafmt(enum v4l2_mbus_pixelcode code)
> +static const struct imx074_datafmt *imx074_find_datafmt(u32 code)
> {
> int i;
>
> @@ -236,7 +236,7 @@ static int imx074_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
> }
>
> static int imx074_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if ((unsigned int)index >= ARRAY_SIZE(imx074_colour_fmts))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c
> index dbd8c14..2e9a535 100644
> --- a/drivers/media/i2c/soc_camera/mt9m001.c
> +++ b/drivers/media/i2c/soc_camera/mt9m001.c
> @@ -53,13 +53,13 @@
>
> /* MT9M001 has only one fixed colorspace per pixelcode */
> struct mt9m001_datafmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
> /* Find a data format by a pixel code in an array */
> static const struct mt9m001_datafmt *mt9m001_find_datafmt(
> - enum v4l2_mbus_pixelcode code, const struct mt9m001_datafmt *fmt,
> + u32 code, const struct mt9m001_datafmt *fmt,
> int n)
> {
> int i;
> @@ -75,14 +75,14 @@ static const struct mt9m001_datafmt mt9m001_colour_fmts[] = {
> * Order important: first natively supported,
> * second supported with a GPIO extender
> */
> - {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> };
>
> static const struct mt9m001_datafmt mt9m001_monochrome_fmts[] = {
> /* Order important - see above */
> - {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG},
> };
>
> struct mt9m001 {
> @@ -563,7 +563,7 @@ static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = {
> };
>
> static int mt9m001_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct mt9m001 *mt9m001 = to_mt9m001(client);
> diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
> index b51e856..5992ea9 100644
> --- a/drivers/media/i2c/soc_camera/mt9m111.c
> +++ b/drivers/media/i2c/soc_camera/mt9m111.c
> @@ -182,23 +182,23 @@ static struct mt9m111_context context_b = {
>
> /* MT9M111 has only one fixed colorspace per pixelcode */
> struct mt9m111_datafmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
> static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
> - {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
> };
>
> struct mt9m111 {
> @@ -218,7 +218,7 @@ struct mt9m111 {
>
> /* Find a data format by a pixel code */
> static const struct mt9m111_datafmt *mt9m111_find_datafmt(struct mt9m111 *mt9m111,
> - enum v4l2_mbus_pixelcode code)
> + u32 code)
> {
> int i;
> for (i = 0; i < ARRAY_SIZE(mt9m111_colour_fmts); i++)
> @@ -331,7 +331,7 @@ static int mt9m111_setup_rect_ctx(struct mt9m111 *mt9m111,
> }
>
> static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rect,
> - int width, int height, enum v4l2_mbus_pixelcode code)
> + int width, int height, u32 code)
> {
> struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
> int ret;
> @@ -345,7 +345,7 @@ static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rec
> if (!ret)
> ret = reg_write(WINDOW_HEIGHT, rect->height);
>
> - if (code != V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) {
> + if (code != MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
> /* IFP in use, down-scaling possible */
> if (!ret)
> ret = mt9m111_setup_rect_ctx(mt9m111, &context_b,
> @@ -393,8 +393,8 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
> if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> return -EINVAL;
>
> - if (mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
> - mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) {
> + if (mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
> + mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
> /* Bayer format - even size lengths */
> rect.width = ALIGN(rect.width, 2);
> rect.height = ALIGN(rect.height, 2);
> @@ -462,7 +462,7 @@ static int mt9m111_g_fmt(struct v4l2_subdev *sd,
> }
>
> static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111,
> - enum v4l2_mbus_pixelcode code)
> + u32 code)
> {
> struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
> u16 data_outfmt2, mask_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER |
> @@ -474,46 +474,46 @@ static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111,
> int ret;
>
> switch (code) {
> - case V4L2_MBUS_FMT_SBGGR8_1X8:
> + case MEDIA_BUS_FMT_SBGGR8_1X8:
> data_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER |
> MT9M111_OUTFMT_RGB;
> break;
> - case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
> + case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
> data_outfmt2 = MT9M111_OUTFMT_BYPASS_IFP | MT9M111_OUTFMT_RGB;
> break;
> - case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
> + case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
> data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555 |
> MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN;
> break;
> - case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
> + case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
> data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555;
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 |
> MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN;
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_BE:
> + case MEDIA_BUS_FMT_RGB565_2X8_BE:
> data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565;
> break;
> - case V4L2_MBUS_FMT_BGR565_2X8_BE:
> + case MEDIA_BUS_FMT_BGR565_2X8_BE:
> data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 |
> MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B;
> break;
> - case V4L2_MBUS_FMT_BGR565_2X8_LE:
> + case MEDIA_BUS_FMT_BGR565_2X8_LE:
> data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 |
> MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN |
> MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B;
> break;
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> data_outfmt2 = 0;
> break;
> - case V4L2_MBUS_FMT_VYUY8_2X8:
> + case MEDIA_BUS_FMT_VYUY8_2X8:
> data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B;
> break;
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN;
> break;
> - case V4L2_MBUS_FMT_YVYU8_2X8:
> + case MEDIA_BUS_FMT_YVYU8_2X8:
> data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN |
> MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B;
> break;
> @@ -542,8 +542,8 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd,
>
> fmt = mt9m111_find_datafmt(mt9m111, mf->code);
>
> - bayer = fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
> - fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE;
> + bayer = fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
> + fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE;
>
> /*
> * With Bayer format enforce even side lengths, but let the user play
> @@ -554,7 +554,7 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd,
> rect->height = ALIGN(rect->height, 2);
> }
>
> - if (fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) {
> + if (fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
> /* IFP bypass mode, no scaling */
> mf->width = rect->width;
> mf->height = rect->height;
> @@ -840,7 +840,7 @@ static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
> };
>
> static int mt9m111_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(mt9m111_colour_fmts))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c
> index f8358c4..35d9c8d 100644
> --- a/drivers/media/i2c/soc_camera/mt9t031.c
> +++ b/drivers/media/i2c/soc_camera/mt9t031.c
> @@ -345,7 +345,7 @@ static int mt9t031_g_fmt(struct v4l2_subdev *sd,
>
> mf->width = mt9t031->rect.width / mt9t031->xskip;
> mf->height = mt9t031->rect.height / mt9t031->yskip;
> - mf->code = V4L2_MBUS_FMT_SBGGR10_1X10;
> + mf->code = MEDIA_BUS_FMT_SBGGR10_1X10;
> mf->colorspace = V4L2_COLORSPACE_SRGB;
> mf->field = V4L2_FIELD_NONE;
>
> @@ -367,7 +367,7 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd,
> xskip = mt9t031_skip(&rect.width, mf->width, MT9T031_MAX_WIDTH);
> yskip = mt9t031_skip(&rect.height, mf->height, MT9T031_MAX_HEIGHT);
>
> - mf->code = V4L2_MBUS_FMT_SBGGR10_1X10;
> + mf->code = MEDIA_BUS_FMT_SBGGR10_1X10;
> mf->colorspace = V4L2_COLORSPACE_SRGB;
>
> /* mt9t031_set_params() doesn't change width and height */
> @@ -385,7 +385,7 @@ static int mt9t031_try_fmt(struct v4l2_subdev *sd,
> &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1,
> &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0);
>
> - mf->code = V4L2_MBUS_FMT_SBGGR10_1X10;
> + mf->code = MEDIA_BUS_FMT_SBGGR10_1X10;
> mf->colorspace = V4L2_COLORSPACE_SRGB;
>
> return 0;
> @@ -673,12 +673,12 @@ static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = {
> };
>
> static int mt9t031_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_SBGGR10_1X10;
> + *code = MEDIA_BUS_FMT_SBGGR10_1X10;
> return 0;
> }
>
> diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c
> index 996d7b4..64f0836 100644
> --- a/drivers/media/i2c/soc_camera/mt9t112.c
> +++ b/drivers/media/i2c/soc_camera/mt9t112.c
> @@ -77,7 +77,7 @@
> struct
> ************************************************************************/
> struct mt9t112_format {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> u16 fmt;
> u16 order;
> @@ -103,32 +103,32 @@ struct mt9t112_priv {
>
> static const struct mt9t112_format mt9t112_cfmts[] = {
> {
> - .code = V4L2_MBUS_FMT_UYVY8_2X8,
> + .code = MEDIA_BUS_FMT_UYVY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .fmt = 1,
> .order = 0,
> }, {
> - .code = V4L2_MBUS_FMT_VYUY8_2X8,
> + .code = MEDIA_BUS_FMT_VYUY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .fmt = 1,
> .order = 1,
> }, {
> - .code = V4L2_MBUS_FMT_YUYV8_2X8,
> + .code = MEDIA_BUS_FMT_YUYV8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .fmt = 1,
> .order = 2,
> }, {
> - .code = V4L2_MBUS_FMT_YVYU8_2X8,
> + .code = MEDIA_BUS_FMT_YVYU8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .fmt = 1,
> .order = 3,
> }, {
> - .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
> + .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .fmt = 8,
> .order = 2,
> }, {
> - .code = V4L2_MBUS_FMT_RGB565_2X8_LE,
> + .code = MEDIA_BUS_FMT_RGB565_2X8_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .fmt = 4,
> .order = 2,
> @@ -840,7 +840,7 @@ static int mt9t112_s_stream(struct v4l2_subdev *sd, int enable)
>
> static int mt9t112_set_params(struct mt9t112_priv *priv,
> const struct v4l2_rect *rect,
> - enum v4l2_mbus_pixelcode code)
> + u32 code)
> {
> int i;
>
> @@ -953,7 +953,7 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd,
> break;
>
> if (i == priv->num_formats) {
> - mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> } else {
> mf->colorspace = mt9t112_cfmts[i].colorspace;
> @@ -967,7 +967,7 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd,
> }
>
> static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct mt9t112_priv *priv = to_mt9t112(client);
> @@ -1101,7 +1101,7 @@ static int mt9t112_probe(struct i2c_client *client,
>
> /* Cannot fail: using the default supported pixel code */
> if (!ret)
> - mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8);
> + mt9t112_set_params(priv, &rect, MEDIA_BUS_FMT_UYVY8_2X8);
> else
> v4l2_clk_put(priv->clk);
>
> diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
> index 99022c8..a246d4d 100644
> --- a/drivers/media/i2c/soc_camera/mt9v022.c
> +++ b/drivers/media/i2c/soc_camera/mt9v022.c
> @@ -85,13 +85,13 @@ MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"");
>
> /* MT9V022 has only one fixed colorspace per pixelcode */
> struct mt9v022_datafmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
> /* Find a data format by a pixel code in an array */
> static const struct mt9v022_datafmt *mt9v022_find_datafmt(
> - enum v4l2_mbus_pixelcode code, const struct mt9v022_datafmt *fmt,
> + u32 code, const struct mt9v022_datafmt *fmt,
> int n)
> {
> int i;
> @@ -107,14 +107,14 @@ static const struct mt9v022_datafmt mt9v022_colour_fmts[] = {
> * Order important: first natively supported,
> * second supported with a GPIO extender
> */
> - {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
> };
>
> static const struct mt9v022_datafmt mt9v022_monochrome_fmts[] = {
> /* Order important - see above */
> - {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG},
> };
>
> /* only registers with different addresses on different mt9v02x sensors */
> @@ -410,13 +410,13 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd,
> * .try_mbus_fmt(), datawidth is from our supported format list
> */
> switch (mf->code) {
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_Y10_1X10:
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_Y10_1X10:
> if (mt9v022->model != MT9V022IX7ATM)
> return -EINVAL;
> break;
> - case V4L2_MBUS_FMT_SBGGR8_1X8:
> - case V4L2_MBUS_FMT_SBGGR10_1X10:
> + case MEDIA_BUS_FMT_SBGGR8_1X8:
> + case MEDIA_BUS_FMT_SBGGR10_1X10:
> if (mt9v022->model != MT9V022IX7ATC)
> return -EINVAL;
> break;
> @@ -443,8 +443,8 @@ static int mt9v022_try_fmt(struct v4l2_subdev *sd,
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct mt9v022 *mt9v022 = to_mt9v022(client);
> const struct mt9v022_datafmt *fmt;
> - int align = mf->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
> - mf->code == V4L2_MBUS_FMT_SBGGR10_1X10;
> + int align = mf->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
> + mf->code == MEDIA_BUS_FMT_SBGGR10_1X10;
>
> v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH,
> MT9V022_MAX_WIDTH, align,
> @@ -759,7 +759,7 @@ static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = {
> };
>
> static int mt9v022_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct mt9v022 *mt9v022 = to_mt9v022(client);
> diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
> index 6c6b1c3..6f2dd90 100644
> --- a/drivers/media/i2c/soc_camera/ov2640.c
> +++ b/drivers/media/i2c/soc_camera/ov2640.c
> @@ -302,7 +302,7 @@ struct ov2640_win_size {
> struct ov2640_priv {
> struct v4l2_subdev subdev;
> struct v4l2_ctrl_handler hdl;
> - enum v4l2_mbus_pixelcode cfmt_code;
> + u32 cfmt_code;
> struct v4l2_clk *clk;
> const struct ov2640_win_size *win;
> };
> @@ -623,11 +623,11 @@ static const struct regval_list ov2640_rgb565_le_regs[] = {
> ENDMARKER,
> };
>
> -static enum v4l2_mbus_pixelcode ov2640_codes[] = {
> - V4L2_MBUS_FMT_YUYV8_2X8,
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_RGB565_2X8_BE,
> - V4L2_MBUS_FMT_RGB565_2X8_LE,
> +static u32 ov2640_codes[] = {
> + MEDIA_BUS_FMT_YUYV8_2X8,
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_RGB565_2X8_BE,
> + MEDIA_BUS_FMT_RGB565_2X8_LE,
> };
>
> /*
> @@ -785,7 +785,7 @@ static const struct ov2640_win_size *ov2640_select_win(u32 *width, u32 *height)
> }
>
> static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
> - enum v4l2_mbus_pixelcode code)
> + u32 code)
> {
> struct ov2640_priv *priv = to_ov2640(client);
> const struct regval_list *selected_cfmt_regs;
> @@ -797,20 +797,20 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
> /* select format */
> priv->cfmt_code = 0;
> switch (code) {
> - case V4L2_MBUS_FMT_RGB565_2X8_BE:
> + case MEDIA_BUS_FMT_RGB565_2X8_BE:
> dev_dbg(&client->dev, "%s: Selected cfmt RGB565 BE", __func__);
> selected_cfmt_regs = ov2640_rgb565_be_regs;
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> dev_dbg(&client->dev, "%s: Selected cfmt RGB565 LE", __func__);
> selected_cfmt_regs = ov2640_rgb565_le_regs;
> break;
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> dev_dbg(&client->dev, "%s: Selected cfmt YUYV (YUV422)", __func__);
> selected_cfmt_regs = ov2640_yuyv_regs;
> break;
> default:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> dev_dbg(&client->dev, "%s: Selected cfmt UYVY", __func__);
> selected_cfmt_regs = ov2640_uyvy_regs;
> }
> @@ -869,7 +869,7 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd,
> if (!priv->win) {
> u32 width = W_SVGA, height = H_SVGA;
> priv->win = ov2640_select_win(&width, &height);
> - priv->cfmt_code = V4L2_MBUS_FMT_UYVY8_2X8;
> + priv->cfmt_code = MEDIA_BUS_FMT_UYVY8_2X8;
> }
>
> mf->width = priv->win->width;
> @@ -877,13 +877,13 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd,
> mf->code = priv->cfmt_code;
>
> switch (mf->code) {
> - case V4L2_MBUS_FMT_RGB565_2X8_BE:
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_BE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> mf->colorspace = V4L2_COLORSPACE_SRGB;
> break;
> default:
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> }
> mf->field = V4L2_FIELD_NONE;
> @@ -899,14 +899,14 @@ static int ov2640_s_fmt(struct v4l2_subdev *sd,
>
>
> switch (mf->code) {
> - case V4L2_MBUS_FMT_RGB565_2X8_BE:
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_BE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> mf->colorspace = V4L2_COLORSPACE_SRGB;
> break;
> default:
> - mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> }
>
> @@ -926,14 +926,14 @@ static int ov2640_try_fmt(struct v4l2_subdev *sd,
> mf->field = V4L2_FIELD_NONE;
>
> switch (mf->code) {
> - case V4L2_MBUS_FMT_RGB565_2X8_BE:
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_BE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> mf->colorspace = V4L2_COLORSPACE_SRGB;
> break;
> default:
> - mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> }
>
> @@ -941,7 +941,7 @@ static int ov2640_try_fmt(struct v4l2_subdev *sd,
> }
>
> static int ov2640_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(ov2640_codes))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c
> index d2daa6a..93ae031 100644
> --- a/drivers/media/i2c/soc_camera/ov5642.c
> +++ b/drivers/media/i2c/soc_camera/ov5642.c
> @@ -602,7 +602,7 @@ static struct regval_list ov5642_default_regs_finalise[] = {
> };
>
> struct ov5642_datafmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
> @@ -618,7 +618,7 @@ struct ov5642 {
> };
>
> static const struct ov5642_datafmt ov5642_colour_fmts[] = {
> - {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
> };
>
> static struct ov5642 *to_ov5642(const struct i2c_client *client)
> @@ -628,7 +628,7 @@ static struct ov5642 *to_ov5642(const struct i2c_client *client)
>
> /* Find a data format by a pixel code in an array */
> static const struct ov5642_datafmt
> - *ov5642_find_datafmt(enum v4l2_mbus_pixelcode code)
> + *ov5642_find_datafmt(u32 code)
> {
> int i;
>
> @@ -840,7 +840,7 @@ static int ov5642_g_fmt(struct v4l2_subdev *sd,
> }
>
> static int ov5642_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(ov5642_colour_fmts))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c
> index ab01598..f4eef2f 100644
> --- a/drivers/media/i2c/soc_camera/ov6650.c
> +++ b/drivers/media/i2c/soc_camera/ov6650.c
> @@ -202,18 +202,18 @@ struct ov6650 {
> unsigned long pclk_limit; /* from host */
> unsigned long pclk_max; /* from resolution and format */
> struct v4l2_fract tpf; /* as requested with s_parm */
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
>
> -static enum v4l2_mbus_pixelcode ov6650_codes[] = {
> - V4L2_MBUS_FMT_YUYV8_2X8,
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_YVYU8_2X8,
> - V4L2_MBUS_FMT_VYUY8_2X8,
> - V4L2_MBUS_FMT_SBGGR8_1X8,
> - V4L2_MBUS_FMT_Y8_1X8,
> +static u32 ov6650_codes[] = {
> + MEDIA_BUS_FMT_YUYV8_2X8,
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_YVYU8_2X8,
> + MEDIA_BUS_FMT_VYUY8_2X8,
> + MEDIA_BUS_FMT_SBGGR8_1X8,
> + MEDIA_BUS_FMT_Y8_1X8,
> };
>
> /* read a register */
> @@ -555,29 +555,29 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
> .height = mf->height << half_scale,
> },
> };
> - enum v4l2_mbus_pixelcode code = mf->code;
> + u32 code = mf->code;
> unsigned long mclk, pclk;
> u8 coma_set = 0, coma_mask = 0, coml_set, coml_mask, clkrc;
> int ret;
>
> /* select color matrix configuration for given color encoding */
> switch (code) {
> - case V4L2_MBUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> dev_dbg(&client->dev, "pixel format GREY8_1X8\n");
> coma_mask |= COMA_RGB | COMA_WORD_SWAP | COMA_BYTE_SWAP;
> coma_set |= COMA_BW;
> break;
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> dev_dbg(&client->dev, "pixel format YUYV8_2X8_LE\n");
> coma_mask |= COMA_RGB | COMA_BW | COMA_BYTE_SWAP;
> coma_set |= COMA_WORD_SWAP;
> break;
> - case V4L2_MBUS_FMT_YVYU8_2X8:
> + case MEDIA_BUS_FMT_YVYU8_2X8:
> dev_dbg(&client->dev, "pixel format YVYU8_2X8_LE (untested)\n");
> coma_mask |= COMA_RGB | COMA_BW | COMA_WORD_SWAP |
> COMA_BYTE_SWAP;
> break;
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> dev_dbg(&client->dev, "pixel format YUYV8_2X8_BE\n");
> if (half_scale) {
> coma_mask |= COMA_RGB | COMA_BW | COMA_WORD_SWAP;
> @@ -587,7 +587,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
> coma_set |= COMA_BYTE_SWAP | COMA_WORD_SWAP;
> }
> break;
> - case V4L2_MBUS_FMT_VYUY8_2X8:
> + case MEDIA_BUS_FMT_VYUY8_2X8:
> dev_dbg(&client->dev, "pixel format YVYU8_2X8_BE (untested)\n");
> if (half_scale) {
> coma_mask |= COMA_RGB | COMA_BW;
> @@ -597,7 +597,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
> coma_set |= COMA_BYTE_SWAP;
> }
> break;
> - case V4L2_MBUS_FMT_SBGGR8_1X8:
> + case MEDIA_BUS_FMT_SBGGR8_1X8:
> dev_dbg(&client->dev, "pixel format SBGGR8_1X8 (untested)\n");
> coma_mask |= COMA_BW | COMA_BYTE_SWAP | COMA_WORD_SWAP;
> coma_set |= COMA_RAW_RGB | COMA_RGB;
> @@ -608,8 +608,8 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
> }
> priv->code = code;
>
> - if (code == V4L2_MBUS_FMT_Y8_1X8 ||
> - code == V4L2_MBUS_FMT_SBGGR8_1X8) {
> + if (code == MEDIA_BUS_FMT_Y8_1X8 ||
> + code == MEDIA_BUS_FMT_SBGGR8_1X8) {
> coml_mask = COML_ONE_CHANNEL;
> coml_set = 0;
> priv->pclk_max = 4000000;
> @@ -619,7 +619,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
> priv->pclk_max = 8000000;
> }
>
> - if (code == V4L2_MBUS_FMT_SBGGR8_1X8)
> + if (code == MEDIA_BUS_FMT_SBGGR8_1X8)
> priv->colorspace = V4L2_COLORSPACE_SRGB;
> else if (code != 0)
> priv->colorspace = V4L2_COLORSPACE_JPEG;
> @@ -697,18 +697,18 @@ static int ov6650_try_fmt(struct v4l2_subdev *sd,
> mf->field = V4L2_FIELD_NONE;
>
> switch (mf->code) {
> - case V4L2_MBUS_FMT_Y10_1X10:
> - mf->code = V4L2_MBUS_FMT_Y8_1X8;
> - case V4L2_MBUS_FMT_Y8_1X8:
> - case V4L2_MBUS_FMT_YVYU8_2X8:
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> - case V4L2_MBUS_FMT_VYUY8_2X8:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_Y10_1X10:
> + mf->code = MEDIA_BUS_FMT_Y8_1X8;
> + case MEDIA_BUS_FMT_Y8_1X8:
> + case MEDIA_BUS_FMT_YVYU8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_VYUY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> break;
> default:
> - mf->code = V4L2_MBUS_FMT_SBGGR8_1X8;
> - case V4L2_MBUS_FMT_SBGGR8_1X8:
> + mf->code = MEDIA_BUS_FMT_SBGGR8_1X8;
> + case MEDIA_BUS_FMT_SBGGR8_1X8:
> mf->colorspace = V4L2_COLORSPACE_SRGB;
> break;
> }
> @@ -717,7 +717,7 @@ static int ov6650_try_fmt(struct v4l2_subdev *sd,
> }
>
> static int ov6650_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(ov6650_codes))
> return -EINVAL;
> @@ -1013,7 +1013,7 @@ static int ov6650_probe(struct i2c_client *client,
> priv->rect.width = W_CIF;
> priv->rect.height = H_CIF;
> priv->half_scale = false;
> - priv->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
> priv->colorspace = V4L2_COLORSPACE_JPEG;
>
> priv->clk = v4l2_clk_get(&client->dev, "mclk");
> diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
> index 970a04e..8daac88 100644
> --- a/drivers/media/i2c/soc_camera/ov772x.c
> +++ b/drivers/media/i2c/soc_camera/ov772x.c
> @@ -376,7 +376,7 @@
> */
>
> struct ov772x_color_format {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> u8 dsp3;
> u8 dsp4;
> @@ -408,7 +408,7 @@ struct ov772x_priv {
> */
> static const struct ov772x_color_format ov772x_cfmts[] = {
> {
> - .code = V4L2_MBUS_FMT_YUYV8_2X8,
> + .code = MEDIA_BUS_FMT_YUYV8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_YUV,
> @@ -416,7 +416,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> .com7 = OFMT_YUV,
> },
> {
> - .code = V4L2_MBUS_FMT_YVYU8_2X8,
> + .code = MEDIA_BUS_FMT_YVYU8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .dsp3 = UV_ON,
> .dsp4 = DSP_OFMT_YUV,
> @@ -424,7 +424,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> .com7 = OFMT_YUV,
> },
> {
> - .code = V4L2_MBUS_FMT_UYVY8_2X8,
> + .code = MEDIA_BUS_FMT_UYVY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_YUV,
> @@ -432,7 +432,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> .com7 = OFMT_YUV,
> },
> {
> - .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
> + .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_YUV,
> @@ -440,7 +440,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> .com7 = FMT_RGB555 | OFMT_RGB,
> },
> {
> - .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
> + .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_YUV,
> @@ -448,7 +448,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> .com7 = FMT_RGB555 | OFMT_RGB,
> },
> {
> - .code = V4L2_MBUS_FMT_RGB565_2X8_LE,
> + .code = MEDIA_BUS_FMT_RGB565_2X8_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_YUV,
> @@ -456,7 +456,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> .com7 = FMT_RGB565 | OFMT_RGB,
> },
> {
> - .code = V4L2_MBUS_FMT_RGB565_2X8_BE,
> + .code = MEDIA_BUS_FMT_RGB565_2X8_BE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_YUV,
> @@ -468,7 +468,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
> * regardless of the COM7 value. We can thus only support 10-bit
> * Bayer until someone figures it out.
> */
> - .code = V4L2_MBUS_FMT_SBGGR10_1X10,
> + .code = MEDIA_BUS_FMT_SBGGR10_1X10,
> .colorspace = V4L2_COLORSPACE_SRGB,
> .dsp3 = 0x0,
> .dsp4 = DSP_OFMT_RAW10,
> @@ -990,7 +990,7 @@ static struct v4l2_subdev_core_ops ov772x_subdev_core_ops = {
> };
>
> static int ov772x_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(ov772x_cfmts))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c
> index bc74224..aa93d2e 100644
> --- a/drivers/media/i2c/soc_camera/ov9640.c
> +++ b/drivers/media/i2c/soc_camera/ov9640.c
> @@ -159,10 +159,10 @@ static const struct ov9640_reg ov9640_regs_rgb[] = {
> { OV9640_MTXS, 0x65 },
> };
>
> -static enum v4l2_mbus_pixelcode ov9640_codes[] = {
> - V4L2_MBUS_FMT_UYVY8_2X8,
> - V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
> - V4L2_MBUS_FMT_RGB565_2X8_LE,
> +static u32 ov9640_codes[] = {
> + MEDIA_BUS_FMT_UYVY8_2X8,
> + MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE,
> + MEDIA_BUS_FMT_RGB565_2X8_LE,
> };
>
> /* read a register */
> @@ -351,22 +351,22 @@ static void ov9640_res_roundup(u32 *width, u32 *height)
> }
>
> /* Prepare necessary register changes depending on color encoding */
> -static void ov9640_alter_regs(enum v4l2_mbus_pixelcode code,
> +static void ov9640_alter_regs(u32 code,
> struct ov9640_reg_alt *alt)
> {
> switch (code) {
> default:
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> alt->com12 = OV9640_COM12_YUV_AVG;
> alt->com13 = OV9640_COM13_Y_DELAY_EN |
> OV9640_COM13_YUV_DLY(0x01);
> break;
> - case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
> + case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
> alt->com7 = OV9640_COM7_RGB;
> alt->com13 = OV9640_COM13_RGB_AVG;
> alt->com15 = OV9640_COM15_RGB_555;
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> alt->com7 = OV9640_COM7_RGB;
> alt->com13 = OV9640_COM13_RGB_AVG;
> alt->com15 = OV9640_COM15_RGB_565;
> @@ -376,7 +376,7 @@ static void ov9640_alter_regs(enum v4l2_mbus_pixelcode code,
>
> /* Setup registers according to resolution and color encoding */
> static int ov9640_write_regs(struct i2c_client *client, u32 width,
> - enum v4l2_mbus_pixelcode code, struct ov9640_reg_alt *alts)
> + u32 code, struct ov9640_reg_alt *alts)
> {
> const struct ov9640_reg *ov9640_regs, *matrix_regs;
> int ov9640_regs_len, matrix_regs_len;
> @@ -419,7 +419,7 @@ static int ov9640_write_regs(struct i2c_client *client, u32 width,
> }
>
> /* select color matrix configuration for given color encoding */
> - if (code == V4L2_MBUS_FMT_UYVY8_2X8) {
> + if (code == MEDIA_BUS_FMT_UYVY8_2X8) {
> matrix_regs = ov9640_regs_yuv;
> matrix_regs_len = ARRAY_SIZE(ov9640_regs_yuv);
> } else {
> @@ -487,7 +487,7 @@ static int ov9640_s_fmt(struct v4l2_subdev *sd,
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct ov9640_reg_alt alts = {0};
> enum v4l2_colorspace cspace;
> - enum v4l2_mbus_pixelcode code = mf->code;
> + u32 code = mf->code;
> int ret;
>
> ov9640_res_roundup(&mf->width, &mf->height);
> @@ -500,13 +500,13 @@ static int ov9640_s_fmt(struct v4l2_subdev *sd,
> return ret;
>
> switch (code) {
> - case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> cspace = V4L2_COLORSPACE_SRGB;
> break;
> default:
> - code = V4L2_MBUS_FMT_UYVY8_2X8;
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + code = MEDIA_BUS_FMT_UYVY8_2X8;
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> cspace = V4L2_COLORSPACE_JPEG;
> }
>
> @@ -527,13 +527,13 @@ static int ov9640_try_fmt(struct v4l2_subdev *sd,
> mf->field = V4L2_FIELD_NONE;
>
> switch (mf->code) {
> - case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> mf->colorspace = V4L2_COLORSPACE_SRGB;
> break;
> default:
> - mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> }
>
> @@ -541,7 +541,7 @@ static int ov9640_try_fmt(struct v4l2_subdev *sd,
> }
>
> static int ov9640_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(ov9640_codes))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c
> index ee9eb63..841dc55 100644
> --- a/drivers/media/i2c/soc_camera/ov9740.c
> +++ b/drivers/media/i2c/soc_camera/ov9740.c
> @@ -392,8 +392,8 @@ static const struct ov9740_reg ov9740_defaults[] = {
> { OV9740_ISP_CTRL19, 0x02 },
> };
>
> -static enum v4l2_mbus_pixelcode ov9740_codes[] = {
> - V4L2_MBUS_FMT_YUYV8_2X8,
> +static u32 ov9740_codes[] = {
> + MEDIA_BUS_FMT_YUYV8_2X8,
> };
>
> /* read a register */
> @@ -674,13 +674,13 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd,
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct ov9740_priv *priv = to_ov9740(sd);
> enum v4l2_colorspace cspace;
> - enum v4l2_mbus_pixelcode code = mf->code;
> + u32 code = mf->code;
> int ret;
>
> ov9740_res_roundup(&mf->width, &mf->height);
>
> switch (code) {
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> cspace = V4L2_COLORSPACE_SRGB;
> break;
> default:
> @@ -710,14 +710,14 @@ static int ov9740_try_fmt(struct v4l2_subdev *sd,
> ov9740_res_roundup(&mf->width, &mf->height);
>
> mf->field = V4L2_FIELD_NONE;
> - mf->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + mf->code = MEDIA_BUS_FMT_YUYV8_2X8;
> mf->colorspace = V4L2_COLORSPACE_SRGB;
>
> return 0;
> }
>
> static int ov9740_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(ov9740_codes))
> return -EINVAL;
> diff --git a/drivers/media/i2c/soc_camera/rj54n1cb0c.c b/drivers/media/i2c/soc_camera/rj54n1cb0c.c
> index 7e6d978..1752428 100644
> --- a/drivers/media/i2c/soc_camera/rj54n1cb0c.c
> +++ b/drivers/media/i2c/soc_camera/rj54n1cb0c.c
> @@ -111,13 +111,13 @@
>
> /* RJ54N1CB0C has only one fixed colorspace per pixelcode */
> struct rj54n1_datafmt {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> };
>
> /* Find a data format by a pixel code in an array */
> static const struct rj54n1_datafmt *rj54n1_find_datafmt(
> - enum v4l2_mbus_pixelcode code, const struct rj54n1_datafmt *fmt,
> + u32 code, const struct rj54n1_datafmt *fmt,
> int n)
> {
> int i;
> @@ -129,15 +129,15 @@ static const struct rj54n1_datafmt *rj54n1_find_datafmt(
> }
>
> static const struct rj54n1_datafmt rj54n1_colour_fmts[] = {
> - {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
> - {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, V4L2_COLORSPACE_SRGB},
> - {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
> + {MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, V4L2_COLORSPACE_SRGB},
> + {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
> };
>
> struct rj54n1_clock_div {
> @@ -486,7 +486,7 @@ static int reg_write_multiple(struct i2c_client *client,
> }
>
> static int rj54n1_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(rj54n1_colour_fmts))
> return -EINVAL;
> @@ -965,11 +965,11 @@ static int rj54n1_try_fmt(struct v4l2_subdev *sd,
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> struct rj54n1 *rj54n1 = to_rj54n1(client);
> const struct rj54n1_datafmt *fmt;
> - int align = mf->code == V4L2_MBUS_FMT_SBGGR10_1X10 ||
> - mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE ||
> - mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE ||
> - mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE ||
> - mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE;
> + int align = mf->code == MEDIA_BUS_FMT_SBGGR10_1X10 ||
> + mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE ||
> + mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE ||
> + mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE ||
> + mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE;
>
> dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n",
> __func__, mf->code, mf->width, mf->height);
> @@ -1025,55 +1025,55 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd,
>
> /* RA_SEL_UL is only relevant for raw modes, ignored otherwise. */
> switch (mf->code) {
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> ret = reg_write(client, RJ54N1_OUT_SEL, 0);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
> break;
> - case V4L2_MBUS_FMT_YVYU8_2X8:
> + case MEDIA_BUS_FMT_YVYU8_2X8:
> ret = reg_write(client, RJ54N1_OUT_SEL, 0);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> ret = reg_write(client, RJ54N1_OUT_SEL, 0x11);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_BE:
> + case MEDIA_BUS_FMT_RGB565_2X8_BE:
> ret = reg_write(client, RJ54N1_OUT_SEL, 0x11);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
> break;
> - case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
> + case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
> ret = reg_write(client, RJ54N1_OUT_SEL, 4);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
> if (!ret)
> ret = reg_write(client, RJ54N1_RA_SEL_UL, 0);
> break;
> - case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
> + case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
> ret = reg_write(client, RJ54N1_OUT_SEL, 4);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
> if (!ret)
> ret = reg_write(client, RJ54N1_RA_SEL_UL, 8);
> break;
> - case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
> + case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
> ret = reg_write(client, RJ54N1_OUT_SEL, 4);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
> if (!ret)
> ret = reg_write(client, RJ54N1_RA_SEL_UL, 0);
> break;
> - case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
> + case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
> ret = reg_write(client, RJ54N1_OUT_SEL, 4);
> if (!ret)
> ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
> if (!ret)
> ret = reg_write(client, RJ54N1_RA_SEL_UL, 8);
> break;
> - case V4L2_MBUS_FMT_SBGGR10_1X10:
> + case MEDIA_BUS_FMT_SBGGR10_1X10:
> ret = reg_write(client, RJ54N1_OUT_SEL, 5);
> break;
> default:
> @@ -1083,7 +1083,7 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd,
> /* Special case: a raw mode with 10 bits of data per clock tick */
> if (!ret)
> ret = reg_set(client, RJ54N1_OCLK_SEL_EN,
> - (mf->code == V4L2_MBUS_FMT_SBGGR10_1X10) << 1, 2);
> + (mf->code == MEDIA_BUS_FMT_SBGGR10_1X10) << 1, 2);
>
> if (ret < 0)
> return ret;
> diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c
> index 416402e..9b85321 100644
> --- a/drivers/media/i2c/soc_camera/tw9910.c
> +++ b/drivers/media/i2c/soc_camera/tw9910.c
> @@ -705,7 +705,7 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd,
>
> mf->width = priv->scale->width;
> mf->height = priv->scale->height;
> - mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> mf->field = V4L2_FIELD_INTERLACED_BT;
>
> @@ -724,7 +724,7 @@ static int tw9910_s_fmt(struct v4l2_subdev *sd,
> /*
> * check color format
> */
> - if (mf->code != V4L2_MBUS_FMT_UYVY8_2X8)
> + if (mf->code != MEDIA_BUS_FMT_UYVY8_2X8)
> return -EINVAL;
>
> mf->colorspace = V4L2_COLORSPACE_JPEG;
> @@ -751,7 +751,7 @@ static int tw9910_try_fmt(struct v4l2_subdev *sd,
> return -EINVAL;
> }
>
> - mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
> mf->colorspace = V4L2_COLORSPACE_JPEG;
>
> /*
> @@ -822,12 +822,12 @@ static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = {
> };
>
> static int tw9910_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_UYVY8_2X8;
> + *code = MEDIA_BUS_FMT_UYVY8_2X8;
> return 0;
> }
>
> diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c
> index 118f8ee..10c735c 100644
> --- a/drivers/media/i2c/sr030pc30.c
> +++ b/drivers/media/i2c/sr030pc30.c
> @@ -165,7 +165,7 @@ struct sr030pc30_info {
> };
>
> struct sr030pc30_format {
> - enum v4l2_mbus_pixelcode code;
> + u32 code;
> enum v4l2_colorspace colorspace;
> u16 ispctl1_reg;
> };
> @@ -201,23 +201,23 @@ static const struct sr030pc30_frmsize sr030pc30_sizes[] = {
> /* supported pixel formats */
> static const struct sr030pc30_format sr030pc30_formats[] = {
> {
> - .code = V4L2_MBUS_FMT_YUYV8_2X8,
> + .code = MEDIA_BUS_FMT_YUYV8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x03,
> }, {
> - .code = V4L2_MBUS_FMT_YVYU8_2X8,
> + .code = MEDIA_BUS_FMT_YVYU8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x02,
> }, {
> - .code = V4L2_MBUS_FMT_VYUY8_2X8,
> + .code = MEDIA_BUS_FMT_VYUY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0,
> }, {
> - .code = V4L2_MBUS_FMT_UYVY8_2X8,
> + .code = MEDIA_BUS_FMT_UYVY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x01,
> }, {
> - .code = V4L2_MBUS_FMT_RGB565_2X8_BE,
> + .code = MEDIA_BUS_FMT_RGB565_2X8_BE,
> .colorspace = V4L2_COLORSPACE_JPEG,
> .ispctl1_reg = 0x40,
> },
> @@ -472,7 +472,7 @@ static int sr030pc30_s_ctrl(struct v4l2_ctrl *ctrl)
> }
>
> static int sr030pc30_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (!code || index >= ARRAY_SIZE(sr030pc30_formats))
> return -EINVAL;
> diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
> index b9dabc9..2042042 100644
> --- a/drivers/media/i2c/tvp514x.c
> +++ b/drivers/media/i2c/tvp514x.c
> @@ -756,12 +756,12 @@ static int tvp514x_s_ctrl(struct v4l2_ctrl *ctrl)
> */
> static int
> tvp514x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_YUYV10_2X10;
> + *code = MEDIA_BUS_FMT_YUYV10_2X10;
> return 0;
> }
>
> @@ -784,7 +784,7 @@ tvp514x_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f)
> /* Calculate height and width based on current standard */
> current_std = decoder->current_std;
>
> - f->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + f->code = MEDIA_BUS_FMT_YUYV8_2X8;
> f->width = decoder->std_list[current_std].width;
> f->height = decoder->std_list[current_std].height;
> f->field = V4L2_FIELD_INTERLACED;
> @@ -942,7 +942,7 @@ static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd,
> if (index != 0)
> return -EINVAL;
>
> - code->code = V4L2_MBUS_FMT_YUYV8_2X8;
> + code->code = MEDIA_BUS_FMT_YUYV8_2X8;
>
> return 0;
> }
> @@ -967,7 +967,7 @@ static int tvp514x_get_pad_format(struct v4l2_subdev *sd,
> return 0;
> }
>
> - format->format.code = V4L2_MBUS_FMT_YUYV8_2X8;
> + format->format.code = MEDIA_BUS_FMT_YUYV8_2X8;
> format->format.width = tvp514x_std_list[decoder->current_std].width;
> format->format.height = tvp514x_std_list[decoder->current_std].height;
> format->format.colorspace = V4L2_COLORSPACE_SMPTE170M;
> @@ -991,7 +991,7 @@ static int tvp514x_set_pad_format(struct v4l2_subdev *sd,
> struct tvp514x_decoder *decoder = to_decoder(sd);
>
> if (fmt->format.field != V4L2_FIELD_INTERLACED ||
> - fmt->format.code != V4L2_MBUS_FMT_YUYV8_2X8 ||
> + fmt->format.code != MEDIA_BUS_FMT_YUYV8_2X8 ||
> fmt->format.colorspace != V4L2_COLORSPACE_SMPTE170M ||
> fmt->format.width != tvp514x_std_list[decoder->current_std].width ||
> fmt->format.height != tvp514x_std_list[decoder->current_std].height)
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index 193e7d6..68cdab9 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -818,12 +818,12 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
> }
>
> static int tvp5150_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index)
> return -EINVAL;
>
> - *code = V4L2_MBUS_FMT_UYVY8_2X8;
> + *code = MEDIA_BUS_FMT_UYVY8_2X8;
> return 0;
> }
>
> @@ -840,7 +840,7 @@ static int tvp5150_mbus_fmt(struct v4l2_subdev *sd,
> f->width = decoder->rect.width;
> f->height = decoder->rect.height;
>
> - f->code = V4L2_MBUS_FMT_UYVY8_2X8;
> + f->code = MEDIA_BUS_FMT_UYVY8_2X8;
> f->field = V4L2_FIELD_SEQ_TB;
> f->colorspace = V4L2_COLORSPACE_SMPTE170M;
>
> diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
> index 51bac76..fe4870e 100644
> --- a/drivers/media/i2c/tvp7002.c
> +++ b/drivers/media/i2c/tvp7002.c
> @@ -626,7 +626,7 @@ static int tvp7002_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f
>
> f->width = bt->width;
> f->height = bt->height;
> - f->code = V4L2_MBUS_FMT_YUYV10_1X20;
> + f->code = MEDIA_BUS_FMT_YUYV10_1X20;
> f->field = device->current_timings->scanmode;
> f->colorspace = device->current_timings->color_space;
>
> @@ -756,12 +756,12 @@ static int tvp7002_s_register(struct v4l2_subdev *sd,
> */
>
> static int tvp7002_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> /* Check requested format index is within range */
> if (index)
> return -EINVAL;
> - *code = V4L2_MBUS_FMT_YUYV10_1X20;
> + *code = MEDIA_BUS_FMT_YUYV10_1X20;
> return 0;
> }
>
> @@ -859,7 +859,7 @@ tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
> if (code->index != 0)
> return -EINVAL;
>
> - code->code = V4L2_MBUS_FMT_YUYV10_1X20;
> + code->code = MEDIA_BUS_FMT_YUYV10_1X20;
>
> return 0;
> }
> @@ -878,7 +878,7 @@ tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
> {
> struct tvp7002 *tvp7002 = to_tvp7002(sd);
>
> - fmt->format.code = V4L2_MBUS_FMT_YUYV10_1X20;
> + fmt->format.code = MEDIA_BUS_FMT_YUYV10_1X20;
> fmt->format.width = tvp7002->current_timings->timings.bt.width;
> fmt->format.height = tvp7002->current_timings->timings.bt.height;
> fmt->format.field = tvp7002->current_timings->scanmode;
> diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c
> index 373f2df..00e7f04 100644
> --- a/drivers/media/i2c/vs6624.c
> +++ b/drivers/media/i2c/vs6624.c
> @@ -45,19 +45,19 @@ struct vs6624 {
> };
>
> static const struct vs6624_format {
> - enum v4l2_mbus_pixelcode mbus_code;
> + u32 mbus_code;
> enum v4l2_colorspace colorspace;
> } vs6624_formats[] = {
> {
> - .mbus_code = V4L2_MBUS_FMT_UYVY8_2X8,
> + .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> },
> {
> - .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8,
> + .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
> .colorspace = V4L2_COLORSPACE_JPEG,
> },
> {
> - .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE,
> + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE,
> .colorspace = V4L2_COLORSPACE_SRGB,
> },
> };
> @@ -65,7 +65,7 @@ static const struct vs6624_format {
> static struct v4l2_mbus_framefmt vs6624_default_fmt = {
> .width = VGA_WIDTH,
> .height = VGA_HEIGHT,
> - .code = V4L2_MBUS_FMT_UYVY8_2X8,
> + .code = MEDIA_BUS_FMT_UYVY8_2X8,
> .field = V4L2_FIELD_NONE,
> .colorspace = V4L2_COLORSPACE_JPEG,
> };
> @@ -558,7 +558,7 @@ static int vs6624_s_ctrl(struct v4l2_ctrl *ctrl)
> }
>
> static int vs6624_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
> - enum v4l2_mbus_pixelcode *code)
> + u32 *code)
> {
> if (index >= ARRAY_SIZE(vs6624_formats))
> return -EINVAL;
> @@ -605,15 +605,15 @@ static int vs6624_s_mbus_fmt(struct v4l2_subdev *sd,
>
> /* set image format */
> switch (fmt->code) {
> - case V4L2_MBUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> vs6624_write(sd, VS6624_IMG_FMT0, 0x0);
> vs6624_write(sd, VS6624_YUV_SETUP, 0x1);
> break;
> - case V4L2_MBUS_FMT_YUYV8_2X8:
> + case MEDIA_BUS_FMT_YUYV8_2X8:
> vs6624_write(sd, VS6624_IMG_FMT0, 0x0);
> vs6624_write(sd, VS6624_YUV_SETUP, 0x3);
> break;
> - case V4L2_MBUS_FMT_RGB565_2X8_LE:
> + case MEDIA_BUS_FMT_RGB565_2X8_LE:
> vs6624_write(sd, VS6624_IMG_FMT0, 0x4);
> vs6624_write(sd, VS6624_RGB_SETUP, 0x0);
> break;
> --
> 1.9.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply
* Edited seccomp.2 man page for review
From: Michael Kerrisk (man-pages) @ 2014-11-08 12:22 UTC (permalink / raw)
To: Kees Cook
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, lkml,
Andy Lutomirski, Linux API, Daniel Borkmann
Hi Kees, (and all),
Thanks for the seccomp.2 draft man page that you provided a few
weeks ago (https://lkml.org/lkml/2014/9/25/685), and my apologies
for the slow follow-up.
I have done some substantial editing of the page. Therefore, could
you please carefully read the revised version below, in case I have
somewhere injected errors.
In addition, I've added a number of FIXMEs to the page source. Could
you please review these.
I've also added long piece to the example section, describing the
program and demonstrating its use. Again, I'd appreciate it if you
could check that over.
One other question about these man-pages changes: should we add
a note in prctl(2) to say that seccomp(2) is preferred over
PR_SET_SECCOMP for new code?
I've appended the revised page at the foot of this mail. You can also
find the branch holding this page (and thus, the series of changes
I've made in Git at:
http://git.kernel.org/cgit/docs/man-pages/man-pages.git/log/?h=draft_seccomp
Feedback either as inline comments to the below, or as a patch based on
the Git branch, would be great!
Cheers,
Michael
.\" Copyright (C) 2014 Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
.\" and Copyright (C) 2012 Will Drewry <wad-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
.\" and Copyright (C) 2008, 2014 Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
.\"
.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
.TH SECCOMP 2 2014-06-23 "Linux" "Linux Programmer's Manual"
.SH NAME
seccomp \- operate on Secure Computing state of the process
.SH SYNOPSIS
.nf
.B #include <linux/seccomp.h>
.B #include <linux/filter.h>
.B #include <linux/audit.h>
.B #include <linux/signal.h>
.\" FIXME Is sys/ptrace.h really required? It is not used in
.\" the example program below.
.B #include <sys/ptrace.h>
.BI "int seccomp(unsigned int " operation ", unsigned int " flags \
", void *" args );
.fi
.SH DESCRIPTION
The
.BR seccomp ()
system call operates on the Secure Computing (seccomp) state of the
calling process.
.\" FIXME: This page various uses the terms "process', "thread" and "task".
.\" Probably only one of these (not "task"!) should be used in all
.\" cases. I suspect it should be "thread".
Currently, Linux supports the following
.IR operation
values:
.TP
.BR SECCOMP_SET_MODE_STRICT
The only system calls that the thread is permitted to make are
.BR read (2),
.BR write (2),
.BR _exit (2),
and
.BR sigreturn (2).
Other system calls result in the delivery of a
.BR SIGKILL
signal
Strict secure computing mode is useful for number-crunching
applications that may need to execute untrusted byte code, perhaps
obtained by reading from a pipe or socket.
This operation is available only if the kernel is configured with
.BR CONFIG_SECCOMP
enabled.
The value of
.IR flags
must be 0, and
.IR args
must be NULL.
This operation is functionally identical to the call:
prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);
.TP
.BR SECCOMP_SET_MODE_FILTER
The system calls allowed are defined by a pointer to a Berkeley Packet
Filter (BPF) passed via
.IR args .
This arguMent is a pointer to a
.IR "struct\ sock_fprog" ;
it can be designed to filter arbitrary system calls and system call
arguments.
If the filter is invalid,
.BR seccomp ()
fails, returning
.BR EACCESS
in
.IR errno .
.\" FIXME I (mtk) reworded the following paragraph substantially.
.\" Please check it.
If
.BR fork (2)
or
.BR clone (2)
is allowed by the filter, any child processes will be constrained to
the same filters and system calls as the parent.
If
.BR execve (2)
is allowed by the filter,
the filters and constraints on permitted system calls are preserved across an
.BR execve (2).
.\" FIXME I (mtk) reworded the following paragraph substantially.
.\" Please check it.
In order to use the
.BR SECCOMP_SET_MODE_FILTER
operation, either the caller must have the
.BR CAP_SYS_ADMIN
capability or the call must be preceded by the call:
prctl(PR_SET_NO_NEW_PRIVS, 1);
Otherwise, the
.BR SECCOMP_SET_MODE_FILTER
operation will fail and return
.BR EACCES
in
.IR errno .
This requirement ensures that filter programs cannot be applied to child
.\" FIXME What does "installed" in the following line mean?
processes with greater privileges than the process that installed them.
If
.BR prctl (2)
or
.BR seccomp (2)
is allowed by the attached filter, further filters may be added.
This will increase evaluation time, but allows for further reduction of
the attack surface during execution of a process.
The
.BR SECCOMP_SET_MODE_FILTER
operation is available only if the kernel is configured with
.BR CONFIG_SECCOMP_FILTER
enabled.
When
.IR flags
is 0, this operation is functionally identical to the call:
prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, args);
The recognized
.IR flags
are:
.RS
.TP
.BR SECCOMP_FILTER_FLAG_TSYNC
When adding a new filter, synchronize all other threads of the calling
process to the same seccomp filter tree.
.\" FIXME Nowhere in this page is the term "filter tree" defined.
.\" There should be a definition somewhere.
.\" Is it: "the set of filters attached to a thread"?
If any thread cannot do this,
the call will not attach the new seccomp filter,
and will fail, returning the first thread ID found that cannot synchronize.
Synchronization will fail if another thread is in
.BR SECCOMP_MODE_STRICT
or if it has attached new seccomp filters to itself,
diverging from the calling thread's filter tree.
.RE
.SH FILTERS
When adding filters via
.BR SECCOMP_SET_MODE_FILTER ,
.IR args
points to a filter program:
.in +4n
.nf
struct sock_fprog {
unsigned short len; /* Number of BPF instructions */
struct sock_filter *filter;
};
.fi
.in
Each program must contain one or more BPF instructions:
.in +4n
.nf
struct sock_filter { /* Filter block */
__u16 code; /* Actual filter code */
__u8 jt; /* Jump true */
__u8 jf; /* Jump false */
__u32 k; /* Generic multiuse field */
};
.fi
.in
When executing the instructions, the BPF program executes over the
system call information made available via:
.in +4n
.nf
struct seccomp_data {
int nr; /* system call number */
__u32 arch; /* AUDIT_ARCH_* value */
__u64 instruction_pointer; /* CPU instruction pointer */
__u64 args[6]; /* up to 6 system call arguments */
};
.fi
.in
.\" FIXME I find the next piece a little hard to understand, so,
.\" some questions:
.\" * If there are multiple filters, in what order are they executed?
.\" (The man page should probably detail the answer to this question.)
.\" * If there are multiple filters, are they all always executed?
.\" I assume not, but the notion that
.\" "the return value for the evaluation of a given system call
.\" will always use the value with the highest precedence"
.\" implies that even that if one filter generates (say)
.\" SECCOMP_RET_ERRNO, then further filters may still be executed,
.\" including one that generates (say) the "higher priority"
.\" SECCOMP_RET_KILL condition.
.\" Can you clarify the above?
A seccomp filter returns one of the values listed below.
If multiple filters exist,
the return value for the evaluation of a given system call
will always use the value with the highest precedence.
(For example,
.BR SECCOMP_RET_KILL
will always take precedence.)
In decreasing order order of precedence,
the values that may be returned by a seccomp filter are:
.TP
.BR SECCOMP_RET_KILL
Results in the task exiting immediately without executing the system call.
The task terminates as though killed by a
.B SIGSYS
signal
.RI ( not
.BR SIGKILL ).
.TP
.BR SECCOMP_RET_TRAP
Results in the kernel sending a
.BR SIGSYS
signal to the triggering task without executing the system call.
.IR siginfo\->si_call_addr
will show the address of the system call instruction, and
.IR siginfo\->si_syscall
and
.IR siginfo\->si_arch
will indicate which system call was attempted.
The program counter will be as though the system call happened
(i.e., it will not point to the system call instruction).
The return value register will contain an architecture\-dependent value;
if resuming execution, set it to something sensible.
(The architecture dependency is because replacing it with
.BR ENOSYS
could overwrite some useful information.)
.\" FIXME The following sentence is the first time that SECCOMP_RET_DATA
.\" is mentioned. SECCOMP_RET_DATA needs to be described in this
.\" man page.
The
.BR SECCOMP_RET_DATA
portion of the return value will be passed as
.IR si_errno .
.BR SIGSYS
triggered by seccomp will have the value
.BR SYS_SECCOMP
in the
.IR si_code
field.
.TP
.BR SECCOMP_RET_ERRNO
.\" FIXME What does "the return value" refer to in the next sentence?
.\" It is not obvious to me.
Results in the lower 16-bits of the return value being passed
to user space as the
.IR errno
without executing the system call.
.TP
.BR SECCOMP_RET_TRACE
When returned, this value will cause the kernel to attempt to notify a
.BR ptrace (2)-based
tracer prior to executing the system call.
.\" FIXME I (mtk) reworded the following sentence substantially.
.\" Please check it.
If there is no tracer present,
the system call is not executed and returns a failure status with
.I errno
set to
.BR ENOSYS .
A tracer will be notified if it requests
.BR PTRACE_O_TRACESECCOMP
using
.IR ptrace(PTRACE_SETOPTIONS) .
The tracer will be notified of a
.BR PTRACE_EVENT_SECCOMP
and the
.BR SECCOMP_RET_DATA
portion of the BPF program return value will be available to the tracer
via
.BR PTRACE_GETEVENTMSG .
The tracer can skip the system call by changing the system call number
to \-1.
Alternatively, the tracer can change the system call
requested by changing the system call to a valid system call number.
If the tracer asks to skip the system call, then the system call will
appear to return the value that the tracer puts in the return value register.
The seccomp check will not be run again after the tracer is notified.
(This means that seccomp-based sandboxes
.B "must not"
allow use of
.BR ptrace (2)\(emeven
of other
sandboxed processes\(emwithout extreme care;
ptracers can use this mechanism to escape.)
.TP
.BR SECCOMP_RET_ALLOW
Results in the system call being executed.
.PP
If multiple filters exist, the return value for the evaluation of a
given system call will always use the highest precedent value.
.\" FIXME The following sentence is the first time that SECCOMP_RET_ACTION
.\" is mentioned. SECCOMP_RET_ACTION needs to be described in this
.\" man page.
Precedence is determined using only the
.BR SECCOMP_RET_ACTION
mask.
When multiple filters return values of the same precedence,
only the
.BR SECCOMP_RET_DATA
from the most recently installed filter will be returned.
.SH RETURN VALUE
On success,
.BR seccomp ()
returns 0.
On error, if
.BR SECCOMP_FILTER_FLAG_TSYNC
was used,
the return value is the thread ID that caused the synchronization failure.
On other errors, \-1 is returned, and
.IR errno
is set to indicate the cause of the error.
.SH ERRORS
.BR seccomp ()
can fail for the following reasons:
.TP
.BR EACCESS
The caller did not have the
.BR CAP_SYS_ADMIN
capability, or had not set
.IR no_new_privs
before using
.BR SECCOMP_SET_MODE_FILTER .
.TP
.BR EFAULT
.IR args
was required to be a valid address.
.TP
.BR EINVAL
.IR operation
is unknown; or
.IR flags
are invalid for the given
.IR operation
.TP
.BR ESRCH
Another thread caused a failure during thread sync, but its ID could not
be determined.
.SH VERSIONS
The
.BR seccomp()
system call first appeared in Linux 3.17.
.\" FIXME Add glibc version
.SH CONFORMING TO
The
.BR seccomp()
system call is a nonstandard Linux extension.
.SH NOTES
.BR seccomp ()
provides a superset of the functionality provided by the
.BR prctl (2)
.BR PR_SET_SECCOMP
operation (which does not support
.IR flags ).
.SH EXAMPLE
.\" FIXME Please carefully review the following new piece that
.\" demonstrates the use of your example program.
The program below accepts four or more arguments.
The first three arguments are a system call number,
a numeric architecture identifier, and an error number.
The program uses these values to construct a BPF filter
that is used at run time to perform the following checks:
.IP [1] 4
If the program is not running on the specified architecture,
the BPF filter causes system calls to fail with the error
.BR ENOSYS .
.IP [2]
If the program attempts to execute the system call with the specified number,
the BPF filter causes the system call to fail, with
.I errno
being set to the specified error number.
.PP
The remaining command-line arguments specify
the pathname and additional arguments of a program
that the example program should attempt to execute using
.BR execve (3)
(a library function that employs the
.BR execve (2)
system call).
Some example runs of the program are shown below.
First, we display the architecture that we are running on (x86-64)
and then construct a shell function that looks up system call
numbers on this architecture:
.nf
.in +4n
$ \fBuname -m\fP
x86_64
$ \fBsyscall_nr() {
cat /usr/src/linux/arch/x86/syscalls/syscall_64.tbl | \\
awk '$2 != "x32" && $3 == "'$1'" { print $1 }'
}\fP
.in
.fi
When the BPF filter rejects a system call (case [2] above),
it causes the system call to fail with the error number
specified on the command line.
In the experiments shown here, we'll use error number 99:
.nf
.in +4n
$ \fBerrno 99\fP
EADDRNOTAVAIL 99 Cannot assign requested address
.in
.fi
In the following example, we attempt to run the command
.BR whoami (1),
but the BPF filter rejects the
.BR execve (2)
system call, so that the command is not even executed:
.nf
.in +4n
$ \fBsyscall_nr execve\fP
59
$ \fB./a.out 59 0xC000003E 99 /bin/whoami\fP
execv: Cannot assign requested address
.in
.fi
In the next example, the BPF filter rejects the
.BR write (2)
system call, so that, although it is successfully started, the
.BR whoami (1)
command is not able to write output:
.nf
.in +4n
$ \fBsyscall_nr write\fP
1
$ \fB./a.out 1 0xC000003E 99 /bin/whoami\fP
.in
.fi
In the final example,
the BPF filter rejects a system call that is not used by the
.BR whoami (1)
command, so it is able to successfully execute and produce output:
.nf
.in +4n
$ \fBsyscall_nr preadv\fP
295
$ \fB./a.out 295 0xC000003E 99 /bin/whoami\fP
cecilia
.in
.fi
.SS Program source
.fi
.nf
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/audit.h>
#include <linux/filter.h>
#include <linux/seccomp.h>
#include <sys/prctl.h>
static int
install_filter(int syscall, int arch, int error)
{
struct sock_filter filter[] = {
/* [0] Load architecture */
BPF_STMT(BPF_LD + BPF_W + BPF_ABS,
(offsetof(struct seccomp_data, arch))),
/* [1] Jump forward 4 instructions on architecture mismatch */
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, arch, 0, 4),
/* [2] Load system call number */
BPF_STMT(BPF_LD + BPF_W + BPF_ABS,
(offsetof(struct seccomp_data, nr))),
/* [3] Jump forward 1 instruction on system call number
mismatch */
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, syscall, 0, 1),
/* [4] Matching architecture and system call: return
specific errno */
BPF_STMT(BPF_RET + BPF_K,
SECCOMP_RET_ERRNO | (error & SECCOMP_RET_DATA)),
/* [5] Destination of system call number mismatch: allow other
system calls */
BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ALLOW),
/* [6] Destination of architecture mismatch: kill process */
BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_KILL),
};
struct sock_fprog prog = {
.len = (unsigned short) (sizeof(filter) / sizeof(filter[0])),
.filter = filter,
};
if (seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)) {
perror("seccomp");
return 1;
}
return 0;
}
int
main(int argc, char **argv)
{
if (argc < 5) {
fprintf(stderr, "Usage:\\n"
"refuse <syscall_nr> <arch> <errno> <prog> [<args>]\\n"
"Hint: AUDIT_ARCH_I386: 0x%X\\n"
" AUDIT_ARCH_X86_64: 0x%X\\n"
"\\n", AUDIT_ARCH_I386, AUDIT_ARCH_X86_64);
exit(EXIT_FAILURE);
}
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
perror("prctl");
exit(EXIT_FAILURE);
}
if (install_filter(strtol(argv[1], NULL, 0),
strtol(argv[2], NULL, 0),
strtol(argv[3], NULL, 0)))
exit(EXIT_FAILURE);
execv(argv[4], &argv[4]);
perror("execv");
exit(EXIT_FAILURE);
}
.fi
.SH SEE ALSO
.BR prctl (2),
.BR ptrace (2),
.BR signal (7),
.BR socket (7)
.sp
.\" FIXME: Is the following the best source of info on the BPF language?
The kernel source file
.IR Documentation/networking/filter.txt .
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply
* Re: [PATCH v8] kernel, add panic_on_warn
From: Prarit Bhargava @ 2014-11-08 13:29 UTC (permalink / raw)
To: David Rientjes
Cc: Andi Kleen, Jonathan Corbet, jbaron-JqFfY2XvxFXQT0dZR+AlfA,
kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rusty Russell,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Fabian Frederick,
isimatu.yasuaki-+CUm20s59erQFUHtdCDX3A, H. Peter Anvin,
Masami Hiramatsu, Andrew Morton, linux-api-u79uwXL29TY76Z2rM5mHXA,
Vivek Goyal
In-Reply-To: <alpine.DEB.2.10.1411071306370.12192-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
On 11/07/2014 04:09 PM, David Rientjes wrote:
> On Fri, 7 Nov 2014, Prarit Bhargava wrote:
>
>> There very much is. Consider a thread that hits a WARN() and then panics. Then
>> somewhere in the panic code the thread hits another WARN() ... and then panics
>> again. Previously this would have caused the system to "finish" panick'ing.
>> Now it makes the system hang.
>>
>
> Then we're back to square one which is what is obviously the intent of
> your patch and the comment that goes along with it:
My original reply pointed out that the comment was wrong.
we want to clear
> panic_on_warn once and not allow multiple panic().
On _this_ thread. The multiple panic across threads cannot occur.
So why not just add
> the necessary synchronization to make sure that happens when WARN()
> happens on two cpus simultaneously?
See above.
P.
>
^ permalink raw reply
* [PATCH v5 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel
From: Boris Brezillon @ 2014-11-08 15:47 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
linux-media-u79uwXL29TY76Z2rM5mHXA, Sakari Ailus
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-api-u79uwXL29TY76Z2rM5mHXA,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA, Guennadi Liakhovetski,
Boris Brezillon
In-Reply-To: <1415369269-5064-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
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.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Acked-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
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(AHSV8888_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
^ permalink raw reply related
* [v6 0/4] ext4: add project quota support
From: Li Xi @ 2014-11-08 17:43 UTC (permalink / raw)
To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-ext4-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn, hch-wEGCiKHe2LqWVfeAwA7xHQ,
dmonakhov-GEFAQzZX7r8dnm+yROfE0A
The following patches propose an implementation of project quota
support for ext4. A project is an aggregate of unrelated inodes
which might scatter in different directories. Inodes that belong
to the same project possess an identical identification i.e.
'project ID', just like every inode has its user/group
identification. The following patches add project quota as
supplement to the former uer/group quota types.
The semantics of ext4 project quota is consistent with XFS. Each
directory can have EXT4_INODE_PROJINHERIT flag set. When the
EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
newly created inode under that directory will have a default project
ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
When this flag is set on a directory, following rules will be kept:
1) The newly created inode under that directory will inherit both
the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
directory.
2) Hard-linking a inode with different project ID into that directory
will fail with errno EXDEV.
3) Renaming a inode with different project ID into that directory
will fail with errno EXDEV. However, 'mv' command will detect this
failure and copy the renamed inode to a new inode in the directory.
Thus, this new inode will inherit both the project ID and
EXT4_INODE_PROJINHERIT flag.
4) If the project quota of that ID is being enforced, statfs() on
that directory will take the quotas as another upper limits along
with the capacity of the file system, i.e. the total block/inode
number will be the minimum of the quota limits and file system
capacity.
Changelog:
* v6 <- v5:
- Add project ID check for cross rename;
- Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
* v5 <- v4:
- Check project feature when set/get project ID;
- Do not check project feature for project quota;
- Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
* v4 <- v3:
- Do not check project feature when set/get project ID;
- Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
- Remove unnecessary change of fs/quota/dquot.c;
- Remove CONFIG_QUOTA_PROJECT.
* v3 <- v2:
- Add EXT4_INODE_PROJINHERIT semantics.
* v2 <- v1:
- Add ioctl interface for setting/getting project;
- Add EXT4_FEATURE_RO_COMPAT_PROJECT;
- Add get_projid() method in struct dquot_operations;
- Add error check of ext4_inode_projid_set/get().
v5: http://www.spinics.net/lists/linux-api/msg04840.html
v4: http://lwn.net/Articles/612972/
v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
Any comments or feedbacks are appreciated.
Regards,
- Li Xi
Li Xi (4):
vfs: adds general codes to enforces project quota limits
ext4: adds project ID support
ext4: adds project quota support
ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
fs/ext4/ext4.h | 31 ++++-
fs/ext4/ialloc.c | 6 +
fs/ext4/inode.c | 29 ++++
fs/ext4/ioctl.c | 330 +++++++++++++++++++++++++++++++-------------
fs/ext4/namei.c | 17 +++
fs/ext4/super.c | 96 +++++++++++--
fs/quota/dquot.c | 35 ++++-
fs/quota/quota.c | 8 +-
fs/quota/quotaio_v2.h | 6 +-
fs/xfs/xfs_fs.h | 17 +--
include/linux/quota.h | 2 +
include/uapi/linux/fs.h | 21 +++
include/uapi/linux/quota.h | 6 +-
13 files changed, 463 insertions(+), 141 deletions(-)
^ permalink raw reply
* [v6 1/4] vfs: adds general codes to enforces project quota limits
From: Li Xi @ 2014-11-08 17:43 UTC (permalink / raw)
To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-ext4-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn, hch-wEGCiKHe2LqWVfeAwA7xHQ,
dmonakhov-GEFAQzZX7r8dnm+yROfE0A
In-Reply-To: <1415468619-31851-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
This patch adds support for a new quota type PRJQUOTA for project quota
enforcement. Also a new method get_projid() is added into dquot_operations
structure.
Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
Signed-off-by: Dmitry Monakhov <dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
---
fs/quota/dquot.c | 35 ++++++++++++++++++++++++++++++-----
fs/quota/quota.c | 8 ++++++--
fs/quota/quotaio_v2.h | 6 ++++--
include/linux/quota.h | 2 ++
include/uapi/linux/quota.h | 6 ++++--
5 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8b663b2..84f9bb1 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1154,8 +1154,8 @@ static int need_print_warning(struct dquot_warn *warn)
return uid_eq(current_fsuid(), warn->w_dq_id.uid);
case GRPQUOTA:
return in_group_p(warn->w_dq_id.gid);
- case PRJQUOTA: /* Never taken... Just make gcc happy */
- return 0;
+ case PRJQUOTA:
+ return 1;
}
return 0;
}
@@ -1394,6 +1394,9 @@ static void __dquot_initialize(struct inode *inode, int type)
/* First get references to structures we might need. */
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
struct kqid qid;
+ kprojid_t projid;
+ int rc;
+
got[cnt] = NULL;
if (type != -1 && cnt != type)
continue;
@@ -1404,6 +1407,10 @@ static void __dquot_initialize(struct inode *inode, int type)
*/
if (inode->i_dquot[cnt])
continue;
+
+ if (!sb_has_quota_active(sb, cnt))
+ continue;
+
init_needed = 1;
switch (cnt) {
@@ -1413,6 +1420,12 @@ static void __dquot_initialize(struct inode *inode, int type)
case GRPQUOTA:
qid = make_kqid_gid(inode->i_gid);
break;
+ case PRJQUOTA:
+ rc = inode->i_sb->dq_op->get_projid(inode, &projid);
+ if (rc)
+ continue;
+ qid = make_kqid_projid(projid);
+ break;
}
got[cnt] = dqget(sb, qid);
}
@@ -2156,7 +2169,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
error = -EROFS;
goto out_fmt;
}
- if (!sb->s_op->quota_write || !sb->s_op->quota_read) {
+ if (!sb->s_op->quota_write || !sb->s_op->quota_read ||
+ (type == PRJQUOTA && sb->dq_op->get_projid == NULL)) {
error = -EINVAL;
goto out_fmt;
}
@@ -2397,8 +2411,19 @@ static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
memset(di, 0, sizeof(*di));
di->d_version = FS_DQUOT_VERSION;
- di->d_flags = dquot->dq_id.type == USRQUOTA ?
- FS_USER_QUOTA : FS_GROUP_QUOTA;
+ switch (dquot->dq_id.type) {
+ case USRQUOTA:
+ di->d_flags = FS_USER_QUOTA;
+ break;
+ case GRPQUOTA:
+ di->d_flags = FS_GROUP_QUOTA;
+ break;
+ case PRJQUOTA:
+ di->d_flags = FS_PROJ_QUOTA;
+ break;
+ default:
+ BUG();
+ }
di->d_id = from_kqid_munged(current_user_ns(), dquot->dq_id);
spin_lock(&dq_data_lock);
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 7562164..795d694 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -30,11 +30,15 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd,
case Q_XGETQSTATV:
case Q_XQUOTASYNC:
break;
- /* allow to query information for dquots we "own" */
+ /*
+ * allow to query information for dquots we "own"
+ * always allow querying project quota
+ */
case Q_GETQUOTA:
case Q_XGETQUOTA:
if ((type == USRQUOTA && uid_eq(current_euid(), make_kuid(current_user_ns(), id))) ||
- (type == GRPQUOTA && in_egroup_p(make_kgid(current_user_ns(), id))))
+ (type == GRPQUOTA && in_egroup_p(make_kgid(current_user_ns(), id))) ||
+ (type == PRJQUOTA))
break;
/*FALLTHROUGH*/
default:
diff --git a/fs/quota/quotaio_v2.h b/fs/quota/quotaio_v2.h
index f1966b4..4e95430 100644
--- a/fs/quota/quotaio_v2.h
+++ b/fs/quota/quotaio_v2.h
@@ -13,12 +13,14 @@
*/
#define V2_INITQMAGICS {\
0xd9c01f11, /* USRQUOTA */\
- 0xd9c01927 /* GRPQUOTA */\
+ 0xd9c01927, /* GRPQUOTA */\
+ 0xd9c03f14, /* PRJQUOTA */\
}
#define V2_INITQVERSIONS {\
1, /* USRQUOTA */\
- 1 /* GRPQUOTA */\
+ 1, /* GRPQUOTA */\
+ 1, /* PRJQUOTA */\
}
/* First generic header */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 80d345a..f1b25f8 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -50,6 +50,7 @@
#undef USRQUOTA
#undef GRPQUOTA
+#undef PRJQUOTA
enum quota_type {
USRQUOTA = 0, /* element used for user quotas */
GRPQUOTA = 1, /* element used for group quotas */
@@ -312,6 +313,7 @@ struct dquot_operations {
/* get reserved quota for delayed alloc, value returned is managed by
* quota code only */
qsize_t *(*get_reserved_space) (struct inode *);
+ int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */
};
struct path;
diff --git a/include/uapi/linux/quota.h b/include/uapi/linux/quota.h
index 3b6cfbe..b2d9486 100644
--- a/include/uapi/linux/quota.h
+++ b/include/uapi/linux/quota.h
@@ -36,11 +36,12 @@
#include <linux/errno.h>
#include <linux/types.h>
-#define __DQUOT_VERSION__ "dquot_6.5.2"
+#define __DQUOT_VERSION__ "dquot_6.6.0"
-#define MAXQUOTAS 2
+#define MAXQUOTAS 3
#define USRQUOTA 0 /* element used for user quotas */
#define GRPQUOTA 1 /* element used for group quotas */
+#define PRJQUOTA 2 /* element used for project quotas */
/*
* Definitions for the default names of the quotas files.
@@ -48,6 +49,7 @@
#define INITQFNAMES { \
"user", /* USRQUOTA */ \
"group", /* GRPQUOTA */ \
+ "project", /* PRJQUOTA */ \
"undefined", \
};
--
1.7.1
^ permalink raw reply related
* [v6 2/4] ext4: adds project ID support
From: Li Xi @ 2014-11-08 17:43 UTC (permalink / raw)
To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-ext4-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn, hch-wEGCiKHe2LqWVfeAwA7xHQ,
dmonakhov-GEFAQzZX7r8dnm+yROfE0A
In-Reply-To: <1415468619-31851-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
This patch adds a new internal field of ext4 inode to save project
identifier. Also a new flag EXT4_INODE_PROJINHERIT is added for
inheriting project ID from parent directory.
Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
---
fs/ext4/ext4.h | 21 +++++++++++++++++----
fs/ext4/ialloc.c | 6 ++++++
fs/ext4/inode.c | 29 +++++++++++++++++++++++++++++
fs/ext4/namei.c | 17 +++++++++++++++++
fs/ext4/super.c | 1 +
5 files changed, 70 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index c55a1fa..d30dfa6 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -386,16 +386,18 @@ struct flex_groups {
#define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
#define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
#define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
+#define EXT4_PROJINHERIT_FL 0x20000000 /* Create with parents projid */
#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
-#define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE 0x004380FF /* User modifiable flags */
+#define EXT4_FL_USER_VISIBLE 0x204BDFFF /* User visible flags */
+#define EXT4_FL_USER_MODIFIABLE 0x204380FF /* User modifiable flags */
/* Flags that should be inherited by new inodes from their parent. */
#define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
- EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL)
+ EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
+ EXT4_PROJINHERIT_FL)
/* Flags that are appropriate for regular files (all but dir-specific ones). */
#define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL))
@@ -443,6 +445,7 @@ enum {
EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */
EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */
EXT4_INODE_INLINE_DATA = 28, /* Data in inode. */
+ EXT4_INODE_PROJINHERIT = 29, /* Create with parents projid */
EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */
};
@@ -694,6 +697,7 @@ struct ext4_inode {
__le32 i_crtime; /* File Creation time */
__le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
__le32 i_version_hi; /* high 32 bits for 64-bit version */
+ __le32 i_projid; /* Project ID */
};
struct move_extent {
@@ -943,6 +947,7 @@ struct ext4_inode_info {
/* Precomputed uuid+inum+igen checksum for seeding inode checksums */
__u32 i_csum_seed;
+ kprojid_t i_projid;
};
/*
@@ -1526,6 +1531,7 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
* GDT_CSUM bits are mutually exclusive.
*/
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
+#define EXT4_FEATURE_RO_COMPAT_PROJECT 0x1000 /* Project quota */
#define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
@@ -1575,7 +1581,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
EXT4_FEATURE_RO_COMPAT_HUGE_FILE |\
EXT4_FEATURE_RO_COMPAT_BIGALLOC |\
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
- EXT4_FEATURE_RO_COMPAT_QUOTA)
+ EXT4_FEATURE_RO_COMPAT_QUOTA |\
+ EXT4_FEATURE_RO_COMPAT_PROJECT)
/*
* Default values for user and/or group using reserved blocks
@@ -1583,6 +1590,11 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
#define EXT4_DEF_RESUID 0
#define EXT4_DEF_RESGID 0
+/*
+ * Default project ID
+ */
+#define EXT4_DEF_PROJID 0
+
#define EXT4_DEF_INODE_READAHEAD_BLKS 32
/*
@@ -2135,6 +2147,7 @@ extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
loff_t lstart, loff_t lend);
extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
+extern int ext4_get_projid(struct inode *inode, kprojid_t *projid);
extern void ext4_da_update_reserve_space(struct inode *inode,
int used, int quota_claim);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index ac644c3..fefb948 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -756,6 +756,12 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
inode->i_gid = dir->i_gid;
} else
inode_init_owner(inode, dir, mode);
+ if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_PROJECT) &&
+ ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) {
+ ei->i_projid = EXT4_I(dir)->i_projid;
+ } else {
+ ei->i_projid = make_kprojid(&init_user_ns, EXT4_DEF_PROJID);
+ }
dquot_initialize(inode);
if (!goal)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3356ab5..1c440be 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3886,6 +3886,14 @@ static inline void ext4_iget_extra_inode(struct inode *inode,
EXT4_I(inode)->i_inline_off = 0;
}
+int ext4_get_projid(struct inode *inode, kprojid_t *projid)
+{
+ if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_RO_COMPAT_PROJECT))
+ return -EOPNOTSUPP;
+ *projid = EXT4_I(inode)->i_projid;
+ return 0;
+}
+
struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
{
struct ext4_iloc iloc;
@@ -3897,6 +3905,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
int block;
uid_t i_uid;
gid_t i_gid;
+ projid_t i_projid;
inode = iget_locked(sb, ino);
if (!inode)
@@ -3946,12 +3955,18 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
inode->i_mode = le16_to_cpu(raw_inode->i_mode);
i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
+ if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_PROJECT))
+ i_projid = (projid_t)le32_to_cpu(raw_inode->i_projid);
+ else
+ i_projid = EXT4_DEF_PROJID;
+
if (!(test_opt(inode->i_sb, NO_UID32))) {
i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
}
i_uid_write(inode, i_uid);
i_gid_write(inode, i_gid);
+ ei->i_projid = make_kprojid(&init_user_ns, i_projid);;
set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
@@ -4181,6 +4196,7 @@ static int ext4_do_update_inode(handle_t *handle,
int need_datasync = 0, set_large_file = 0;
uid_t i_uid;
gid_t i_gid;
+ projid_t i_projid;
spin_lock(&ei->i_raw_lock);
@@ -4193,6 +4209,7 @@ static int ext4_do_update_inode(handle_t *handle,
raw_inode->i_mode = cpu_to_le16(inode->i_mode);
i_uid = i_uid_read(inode);
i_gid = i_gid_read(inode);
+ i_projid = from_kprojid(&init_user_ns, ei->i_projid);
if (!(test_opt(inode->i_sb, NO_UID32))) {
raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
@@ -4272,6 +4289,18 @@ static int ext4_do_update_inode(handle_t *handle,
}
}
+ BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
+ EXT4_FEATURE_RO_COMPAT_PROJECT) &&
+ i_projid != EXT4_DEF_PROJID);
+ if (i_projid != EXT4_DEF_PROJID &&
+ (EXT4_INODE_SIZE(inode->i_sb) <= EXT4_GOOD_OLD_INODE_SIZE ||
+ (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid)))) {
+ spin_unlock(&ei->i_raw_lock);
+ err = -EFBIG;
+ goto out_brelse;
+ }
+ raw_inode->i_projid = cpu_to_le32(i_projid);
+
ext4_inode_csum_set(inode, raw_inode, ei);
spin_unlock(&ei->i_raw_lock);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 4262118..160a743 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2939,6 +2939,11 @@ static int ext4_link(struct dentry *old_dentry,
if (inode->i_nlink >= EXT4_LINK_MAX)
return -EMLINK;
+ if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
+ (!projid_eq(EXT4_I(dir)->i_projid,
+ EXT4_I(old_dentry->d_inode)->i_projid)))
+ return -EXDEV;
+
dquot_initialize(dir);
retry:
@@ -3218,6 +3223,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
int credits;
u8 old_file_type;
+ if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT)) &&
+ (!projid_eq(EXT4_I(new_dir)->i_projid,
+ EXT4_I(old_dentry->d_inode)->i_projid)))
+ return -EXDEV;
+
dquot_initialize(old.dir);
dquot_initialize(new.dir);
@@ -3396,6 +3406,13 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
u8 new_file_type;
int retval;
+ if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT)) &&
+ ((!projid_eq(EXT4_I(new_dir)->i_projid,
+ EXT4_I(old_dentry->d_inode)->i_projid)) ||
+ (!projid_eq(EXT4_I(old_dir)->i_projid,
+ EXT4_I(new_dentry->d_inode)->i_projid))))
+ return -EXDEV;
+
dquot_initialize(old.dir);
dquot_initialize(new.dir);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2c9e686..d8a348d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1077,6 +1077,7 @@ static const struct dquot_operations ext4_quota_operations = {
.write_info = ext4_write_info,
.alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy,
+ .get_projid = ext4_get_projid,
};
static const struct quotactl_ops ext4_qctl_operations = {
--
1.7.1
^ permalink raw reply related
* [v6 3/4] ext4: adds project quota support
From: Li Xi @ 2014-11-08 17:43 UTC (permalink / raw)
To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-ext4-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn, hch-wEGCiKHe2LqWVfeAwA7xHQ,
dmonakhov-GEFAQzZX7r8dnm+yROfE0A
In-Reply-To: <1415468619-31851-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
This patch adds mount options for enabling/disabling project quota
accounting and enforcement. A new specific inode is also used for
project quota accounting.
Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
Signed-off-by: Dmitry Monakhov <dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
---
fs/ext4/ext4.h | 8 +++-
fs/ext4/super.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 90 insertions(+), 13 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index d30dfa6..4c797da 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -217,6 +217,7 @@ struct ext4_io_submit {
#define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
#define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
#define EXT4_JOURNAL_INO 8 /* Journal inode */
+#define EXT4_PRJ_QUOTA_INO 9 /* Project quota inode */
/* First non-reserved inode for old ext4 filesystems */
#define EXT4_GOOD_OLD_FIRST_INO 11
@@ -991,6 +992,7 @@ struct ext4_inode_info {
#define EXT4_MOUNT_DIOREAD_NOLOCK 0x400000 /* Enable support for dio read nolocking */
#define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
+#define EXT4_MOUNT_PRJQUOTA 0x2000000 /* Project quota support */
#define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
#define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
#define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
@@ -1166,7 +1168,8 @@ struct ext4_super_block {
__le32 s_grp_quota_inum; /* inode for tracking group quota */
__le32 s_overhead_clusters; /* overhead blocks/clusters in fs */
__le32 s_backup_bgs[2]; /* groups with sparse_super2 SBs */
- __le32 s_reserved[106]; /* Padding to the end of the block */
+ __le32 s_prj_quota_inum; /* inode for tracking project quota */
+ __le32 s_reserved[105]; /* Padding to the end of the block */
__le32 s_checksum; /* crc32c(superblock) */
};
@@ -1181,7 +1184,7 @@ struct ext4_super_block {
#define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */
/* Number of quota types we support */
-#define EXT4_MAXQUOTAS 2
+#define EXT4_MAXQUOTAS 3
/*
* fourth extended-fs super-block data in memory
@@ -1372,6 +1375,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
ino == EXT4_BOOT_LOADER_INO ||
ino == EXT4_JOURNAL_INO ||
ino == EXT4_RESIZE_INO ||
+ ino == EXT4_PRJ_QUOTA_INO ||
(ino >= EXT4_FIRST_INO(sb) &&
ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d8a348d..564fbd7 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1045,8 +1045,8 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page,
}
#ifdef CONFIG_QUOTA
-#define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group")
-#define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
+static char *quotatypes[] = INITQFNAMES;
+#define QTYPE2NAME(t) (quotatypes[t])
static int ext4_write_dquot(struct dquot *dquot);
static int ext4_acquire_dquot(struct dquot *dquot);
@@ -1138,10 +1138,11 @@ enum {
Opt_journal_path, Opt_journal_checksum, Opt_journal_async_commit,
Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
Opt_data_err_abort, Opt_data_err_ignore,
- Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
+ Opt_usrjquota, Opt_grpjquota, Opt_prjjquota,
+ Opt_offusrjquota, Opt_offgrpjquota, Opt_offprjjquota,
Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err,
- Opt_usrquota, Opt_grpquota, Opt_i_version,
+ Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version,
Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit,
Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity,
Opt_inode_readahead_blks, Opt_journal_ioprio,
@@ -1192,6 +1193,8 @@ static const match_table_t tokens = {
{Opt_usrjquota, "usrjquota=%s"},
{Opt_offgrpjquota, "grpjquota="},
{Opt_grpjquota, "grpjquota=%s"},
+ {Opt_offprjjquota, "prjjquota="},
+ {Opt_prjjquota, "prjjquota=%s"},
{Opt_jqfmt_vfsold, "jqfmt=vfsold"},
{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
@@ -1199,6 +1202,7 @@ static const match_table_t tokens = {
{Opt_noquota, "noquota"},
{Opt_quota, "quota"},
{Opt_usrquota, "usrquota"},
+ {Opt_prjquota, "prjquota"},
{Opt_barrier, "barrier=%u"},
{Opt_barrier, "barrier"},
{Opt_nobarrier, "nobarrier"},
@@ -1411,12 +1415,17 @@ static const struct mount_opts {
MOPT_SET | MOPT_Q},
{Opt_grpquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_GRPQUOTA,
MOPT_SET | MOPT_Q},
+ {Opt_prjquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_PRJQUOTA,
+ MOPT_SET | MOPT_Q},
{Opt_noquota, (EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA |
- EXT4_MOUNT_GRPQUOTA), MOPT_CLEAR | MOPT_Q},
+ EXT4_MOUNT_GRPQUOTA | EXT4_MOUNT_PRJQUOTA),
+ MOPT_CLEAR | MOPT_Q},
{Opt_usrjquota, 0, MOPT_Q},
{Opt_grpjquota, 0, MOPT_Q},
+ {Opt_prjjquota, 0, MOPT_Q},
{Opt_offusrjquota, 0, MOPT_Q},
{Opt_offgrpjquota, 0, MOPT_Q},
+ {Opt_offprjjquota, 0, MOPT_Q},
{Opt_jqfmt_vfsold, QFMT_VFS_OLD, MOPT_QFMT},
{Opt_jqfmt_vfsv0, QFMT_VFS_V0, MOPT_QFMT},
{Opt_jqfmt_vfsv1, QFMT_VFS_V1, MOPT_QFMT},
@@ -1439,10 +1448,14 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
return set_qf_name(sb, USRQUOTA, &args[0]);
else if (token == Opt_grpjquota)
return set_qf_name(sb, GRPQUOTA, &args[0]);
+ else if (token == Opt_prjjquota)
+ return set_qf_name(sb, PRJQUOTA, &args[0]);
else if (token == Opt_offusrjquota)
return clear_qf_name(sb, USRQUOTA);
else if (token == Opt_offgrpjquota)
return clear_qf_name(sb, GRPQUOTA);
+ else if (token == Opt_offprjjquota)
+ return clear_qf_name(sb, PRJQUOTA);
#endif
switch (token) {
case Opt_noacl:
@@ -1668,19 +1681,28 @@ static int parse_options(char *options, struct super_block *sb,
}
#ifdef CONFIG_QUOTA
if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) &&
- (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) {
+ (test_opt(sb, USRQUOTA) ||
+ test_opt(sb, GRPQUOTA) ||
+ test_opt(sb, PRJQUOTA))) {
ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA "
"feature is enabled");
return 0;
}
- if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
+ if (sbi->s_qf_names[USRQUOTA] ||
+ sbi->s_qf_names[GRPQUOTA] ||
+ sbi->s_qf_names[PRJQUOTA]) {
if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA])
clear_opt(sb, USRQUOTA);
if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA])
clear_opt(sb, GRPQUOTA);
- if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) {
+ if (test_opt(sb, PRJQUOTA) && sbi->s_qf_names[PRJQUOTA])
+ clear_opt(sb, PRJQUOTA);
+
+ if (test_opt(sb, GRPQUOTA) ||
+ test_opt(sb, USRQUOTA) ||
+ test_opt(sb, PRJQUOTA)) {
ext4_msg(sb, KERN_ERR, "old and new quota "
"format mixing");
return 0;
@@ -1734,6 +1756,9 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
if (sbi->s_qf_names[GRPQUOTA])
seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
+
+ if (sbi->s_qf_names[PRJQUOTA])
+ seq_printf(seq, ",prjjquota=%s", sbi->s_qf_names[PRJQUOTA]);
#endif
}
@@ -5030,6 +5055,46 @@ restore_opts:
return err;
}
+static int ext4_statfs_project(struct super_block *sb,
+ kprojid_t projid, struct kstatfs *buf)
+{
+ struct kqid qid;
+ struct dquot *dquot;
+ u64 limit;
+ u64 curblock;
+
+ qid = make_kqid_projid(projid);
+ dquot = dqget(sb, qid);
+ if (!dquot)
+ return -ESRCH;
+ spin_lock(&dq_data_lock);
+
+ limit = dquot->dq_dqb.dqb_bsoftlimit ?
+ dquot->dq_dqb.dqb_bsoftlimit :
+ dquot->dq_dqb.dqb_bhardlimit;
+ if (limit && buf->f_blocks * buf->f_bsize > limit) {
+ curblock = dquot->dq_dqb.dqb_curspace / buf->f_bsize;
+ buf->f_blocks = limit / buf->f_bsize;
+ buf->f_bfree = buf->f_bavail =
+ (buf->f_blocks > curblock) ?
+ (buf->f_blocks - curblock) : 0;
+ }
+
+ limit = dquot->dq_dqb.dqb_isoftlimit ?
+ dquot->dq_dqb.dqb_isoftlimit :
+ dquot->dq_dqb.dqb_ihardlimit;
+ if (limit && buf->f_files > limit) {
+ buf->f_files = limit;
+ buf->f_ffree =
+ (buf->f_files > dquot->dq_dqb.dqb_curinodes) ?
+ (buf->f_files - dquot->dq_dqb.dqb_curinodes) : 0;
+ }
+
+ spin_unlock(&dq_data_lock);
+ dqput(dquot);
+ return 0;
+}
+
static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
@@ -5038,6 +5103,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
ext4_fsblk_t overhead = 0, resv_blocks;
u64 fsid;
s64 bfree;
+ struct inode *inode = dentry->d_inode;
resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
if (!test_opt(sb, MINIX_DF))
@@ -5062,6 +5128,9 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
+ if (ext4_test_inode_flag(inode, EXT4_INODE_PROJINHERIT) &&
+ sb_has_quota_limits_enabled(sb, PRJQUOTA))
+ ext4_statfs_project(sb, EXT4_I(inode)->i_projid, buf);
return 0;
}
@@ -5142,7 +5211,9 @@ static int ext4_mark_dquot_dirty(struct dquot *dquot)
/* Are we journaling quotas? */
if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) ||
- sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
+ sbi->s_qf_names[USRQUOTA] ||
+ sbi->s_qf_names[GRPQUOTA] ||
+ sbi->s_qf_names[PRJQUOTA]) {
dquot_mark_dquot_dirty(dquot);
return ext4_write_dquot(dquot);
} else {
@@ -5226,7 +5297,8 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
struct inode *qf_inode;
unsigned long qf_inums[EXT4_MAXQUOTAS] = {
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
- le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
+ le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum),
+ le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum)
};
BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA));
@@ -5254,7 +5326,8 @@ static int ext4_enable_quotas(struct super_block *sb)
int type, err = 0;
unsigned long qf_inums[EXT4_MAXQUOTAS] = {
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
- le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
+ le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum),
+ le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum)
};
sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
--
1.7.1
^ permalink raw reply related
* [v6 4/4] ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
From: Li Xi @ 2014-11-08 17:43 UTC (permalink / raw)
To: linux-fsdevel, linux-ext4, linux-api, tytso, adilger, jack, viro,
hch, dmonakhov
In-Reply-To: <1415468619-31851-1-git-send-email-lixi@ddn.com>
This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
support for ext4. The interface is kept consistent with
XFS_IOC_FSGETXATTR/XFS_IOC_FSGETXATTR.
Signed-off-by: Li Xi <lixi@ddn.com>
---
fs/ext4/ext4.h | 2 +
fs/ext4/ioctl.c | 330 +++++++++++++++++++++++++++++++++--------------
fs/xfs/xfs_fs.h | 17 +--
include/uapi/linux/fs.h | 21 +++
4 files changed, 257 insertions(+), 113 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 4c797da..2d20677 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -617,6 +617,8 @@ enum {
#define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
#define EXT4_IOC_SWAP_BOOT _IO('f', 17)
#define EXT4_IOC_PRECACHE_EXTENTS _IO('f', 18)
+#define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR
+#define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR
#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
/*
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index bfda18a..d38b4e8 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -14,6 +14,8 @@
#include <linux/compat.h>
#include <linux/mount.h>
#include <linux/file.h>
+#include <linux/quotaops.h>
+#include <linux/quota.h>
#include <asm/uaccess.h>
#include "ext4_jbd2.h"
#include "ext4.h"
@@ -198,126 +200,220 @@ journal_err_out:
return err;
}
-long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+static int ext4_ioctl_setflags(struct file *filp, unsigned int flags)
{
struct inode *inode = file_inode(filp);
- struct super_block *sb = inode->i_sb;
struct ext4_inode_info *ei = EXT4_I(inode);
- unsigned int flags;
+ handle_t *handle = NULL;
+ int err, migrate = 0;
+ struct ext4_iloc iloc;
+ unsigned int oldflags, mask, i;
+ unsigned int jflag;
- ext4_debug("cmd = %u, arg = %lu\n", cmd, arg);
+ if (!inode_owner_or_capable(inode))
+ return -EACCES;
- switch (cmd) {
- case EXT4_IOC_GETFLAGS:
- ext4_get_inode_flags(ei);
- flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
- return put_user(flags, (int __user *) arg);
- case EXT4_IOC_SETFLAGS: {
- handle_t *handle = NULL;
- int err, migrate = 0;
- struct ext4_iloc iloc;
- unsigned int oldflags, mask, i;
- unsigned int jflag;
+ err = mnt_want_write_file(filp);
+ if (err)
+ return err;
- if (!inode_owner_or_capable(inode))
- return -EACCES;
+ flags = ext4_mask_flags(inode->i_mode, flags);
- if (get_user(flags, (int __user *) arg))
- return -EFAULT;
+ err = -EPERM;
+ mutex_lock(&inode->i_mutex);
+ /* Is it quota file? Do not allow user to mess with it */
+ if (IS_NOQUOTA(inode))
+ goto flags_out;
- err = mnt_want_write_file(filp);
- if (err)
- return err;
+ oldflags = ei->i_flags;
- flags = ext4_mask_flags(inode->i_mode, flags);
+ /* The JOURNAL_DATA flag is modifiable only by root */
+ jflag = flags & EXT4_JOURNAL_DATA_FL;
- err = -EPERM;
- mutex_lock(&inode->i_mutex);
- /* Is it quota file? Do not allow user to mess with it */
- if (IS_NOQUOTA(inode))
+ /*
+ * The IMMUTABLE and APPEND_ONLY flags can only be changed by
+ * the relevant capability.
+ *
+ * This test looks nicer. Thanks to Pauline Middelink
+ */
+ if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
+ if (!capable(CAP_LINUX_IMMUTABLE))
goto flags_out;
+ }
- oldflags = ei->i_flags;
-
- /* The JOURNAL_DATA flag is modifiable only by root */
- jflag = flags & EXT4_JOURNAL_DATA_FL;
-
- /*
- * The IMMUTABLE and APPEND_ONLY flags can only be changed by
- * the relevant capability.
- *
- * This test looks nicer. Thanks to Pauline Middelink
- */
- if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
- if (!capable(CAP_LINUX_IMMUTABLE))
- goto flags_out;
- }
-
- /*
- * The JOURNAL_DATA flag can only be changed by
- * the relevant capability.
- */
- if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
- if (!capable(CAP_SYS_RESOURCE))
- goto flags_out;
- }
- if ((flags ^ oldflags) & EXT4_EXTENTS_FL)
- migrate = 1;
-
+ /*
+ * The JOURNAL_DATA flag can only be changed by
+ * the relevant capability.
+ */
+ if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
+ if (!capable(CAP_SYS_RESOURCE))
+ goto flags_out;
+ }
+ if ((flags ^ oldflags) & EXT4_EXTENTS_FL)
+ migrate = 1;
if (flags & EXT4_EOFBLOCKS_FL) {
- /* we don't support adding EOFBLOCKS flag */
- if (!(oldflags & EXT4_EOFBLOCKS_FL)) {
- err = -EOPNOTSUPP;
- goto flags_out;
- }
- } else if (oldflags & EXT4_EOFBLOCKS_FL)
- ext4_truncate(inode);
-
- handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
- if (IS_ERR(handle)) {
- err = PTR_ERR(handle);
+ /* we don't support adding EOFBLOCKS flag */
+ if (!(oldflags & EXT4_EOFBLOCKS_FL)) {
+ err = -EOPNOTSUPP;
goto flags_out;
}
- if (IS_SYNC(inode))
- ext4_handle_sync(handle);
- err = ext4_reserve_inode_write(handle, inode, &iloc);
- if (err)
- goto flags_err;
-
- for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {
- if (!(mask & EXT4_FL_USER_MODIFIABLE))
- continue;
- if (mask & flags)
- ext4_set_inode_flag(inode, i);
- else
- ext4_clear_inode_flag(inode, i);
- }
+ } else if (oldflags & EXT4_EOFBLOCKS_FL)
+ ext4_truncate(inode);
- ext4_set_inode_flags(inode);
- inode->i_ctime = ext4_current_time(inode);
+ handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
+ if (IS_ERR(handle)) {
+ err = PTR_ERR(handle);
+ goto flags_out;
+ }
+ if (IS_SYNC(inode))
+ ext4_handle_sync(handle);
+ err = ext4_reserve_inode_write(handle, inode, &iloc);
+ if (err)
+ goto flags_err;
+
+ for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {
+ if (!(mask & EXT4_FL_USER_MODIFIABLE))
+ continue;
+ if (mask & flags)
+ ext4_set_inode_flag(inode, i);
+ else
+ ext4_clear_inode_flag(inode, i);
+ }
- err = ext4_mark_iloc_dirty(handle, inode, &iloc);
-flags_err:
- ext4_journal_stop(handle);
- if (err)
- goto flags_out;
+ ext4_set_inode_flags(inode);
+ inode->i_ctime = ext4_current_time(inode);
- if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
- err = ext4_change_inode_journal_flag(inode, jflag);
- if (err)
- goto flags_out;
- if (migrate) {
- if (flags & EXT4_EXTENTS_FL)
- err = ext4_ext_migrate(inode);
- else
- err = ext4_ind_migrate(inode);
- }
+ err = ext4_mark_iloc_dirty(handle, inode, &iloc);
+flags_err:
+ ext4_journal_stop(handle);
+ if (err)
+ goto flags_out;
+
+ if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
+ err = ext4_change_inode_journal_flag(inode, jflag);
+ if (err)
+ goto flags_out;
+ if (migrate) {
+ if (flags & EXT4_EXTENTS_FL)
+ err = ext4_ext_migrate(inode);
+ else
+ err = ext4_ind_migrate(inode);
+ }
flags_out:
- mutex_unlock(&inode->i_mutex);
- mnt_drop_write_file(filp);
+ mutex_unlock(&inode->i_mutex);
+ mnt_drop_write_file(filp);
+ return err;
+}
+
+static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
+{
+ struct inode *inode = file_inode(filp);
+ struct super_block *sb = inode->i_sb;
+ struct ext4_inode_info *ei = EXT4_I(inode);
+ int err;
+ handle_t *handle;
+ kprojid_t kprojid;
+ struct ext4_iloc iloc;
+ struct ext4_inode *raw_inode;
+
+ struct dquot *transfer_to[EXT4_MAXQUOTAS] = { };
+
+ /* Make sure caller can change project. */
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
+
+ if (projid != EXT4_DEF_PROJID
+ && !EXT4_HAS_RO_COMPAT_FEATURE(sb,
+ EXT4_FEATURE_RO_COMPAT_PROJECT))
+ return -EOPNOTSUPP;
+
+ if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
+ EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ BUG_ON(__kprojid_val(EXT4_I(inode)->i_projid)
+ != EXT4_DEF_PROJID);
+ if (projid != EXT4_DEF_PROJID)
+ return -EOPNOTSUPP;
+ else
+ return 0;
+ }
+
+ kprojid = make_kprojid(&init_user_ns, (projid_t)projid);
+
+ if (projid_eq(kprojid, EXT4_I(inode)->i_projid))
+ return 0;
+
+ err = mnt_want_write_file(filp);
+ if (err)
return err;
+
+ err = -EPERM;
+ mutex_lock(&inode->i_mutex);
+ /* Is it quota file? Do not allow user to mess with it */
+ if (IS_NOQUOTA(inode))
+ goto project_out;
+
+ dquot_initialize(inode);
+
+ handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
+ EXT4_QUOTA_INIT_BLOCKS(sb) +
+ EXT4_QUOTA_DEL_BLOCKS(sb) + 3);
+ if (IS_ERR(handle)) {
+ err = PTR_ERR(handle);
+ goto project_out;
+ }
+
+ err = ext4_reserve_inode_write(handle, inode, &iloc);
+ if (err)
+ goto project_stop;
+
+ raw_inode = ext4_raw_inode(&iloc);
+ if ((EXT4_INODE_SIZE(sb) <=
+ EXT4_GOOD_OLD_INODE_SIZE) ||
+ (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))) {
+ err = -EFBIG;
+ goto project_stop;
}
+
+ transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
+ if (!transfer_to[PRJQUOTA])
+ goto project_set;
+
+ err = __dquot_transfer(inode, transfer_to);
+ dqput(transfer_to[PRJQUOTA]);
+ if (err)
+ goto project_stop;
+
+project_set:
+ EXT4_I(inode)->i_projid = kprojid;
+ inode->i_ctime = ext4_current_time(inode);
+ err = ext4_mark_iloc_dirty(handle, inode, &iloc);
+project_stop:
+ ext4_journal_stop(handle);
+project_out:
+ mutex_unlock(&inode->i_mutex);
+ mnt_drop_write_file(filp);
+ return err;
+}
+
+long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ struct inode *inode = file_inode(filp);
+ struct super_block *sb = inode->i_sb;
+ struct ext4_inode_info *ei = EXT4_I(inode);
+ unsigned int flags;
+
+ ext4_debug("cmd = %u, arg = %lu\n", cmd, arg);
+
+ switch (cmd) {
+ case EXT4_IOC_GETFLAGS:
+ ext4_get_inode_flags(ei);
+ flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
+ return put_user(flags, (int __user *) arg);
+ case EXT4_IOC_SETFLAGS:
+ if (get_user(flags, (int __user *) arg))
+ return -EFAULT;
+ return ext4_ioctl_setflags(filp, flags);
case EXT4_IOC_GETVERSION:
case EXT4_IOC_GETVERSION_OLD:
return put_user(inode->i_generation, (int __user *) arg);
@@ -617,7 +713,45 @@ resizefs_out:
}
case EXT4_IOC_PRECACHE_EXTENTS:
return ext4_ext_precache(inode);
+ case EXT4_IOC_FSGETXATTR:
+ {
+ struct fsxattr fa;
+
+ memset(&fa, 0, sizeof(struct fsxattr));
+
+ ext4_get_inode_flags(ei);
+ fa.fsx_xflags = ei->i_flags & EXT4_FL_USER_VISIBLE;
+
+ if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
+ EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
+ EXT4_I(inode)->i_projid);
+ }
+
+ if (copy_to_user((struct fsxattr __user *)arg,
+ &fa, sizeof(fa)))
+ return -EFAULT;
+ return 0;
+ }
+ case EXT4_IOC_FSSETXATTR:
+ {
+ struct fsxattr fa;
+ int err;
+
+ if (copy_from_user(&fa, (struct fsxattr __user *)arg,
+ sizeof(fa)))
+ return -EFAULT;
+ err = ext4_ioctl_setflags(filp, fa.fsx_xflags);
+ if (err)
+ return err;
+
+ err = ext4_ioctl_setproject(filp, fa.fsx_projid);
+ if (err)
+ return err;
+
+ return 0;
+ }
default:
return -ENOTTY;
}
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 18dc721..5dd6013 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -36,19 +36,6 @@ struct dioattr {
#endif
/*
- * Structure for XFS_IOC_FSGETXATTR[A] and XFS_IOC_FSSETXATTR.
- */
-#ifndef HAVE_FSXATTR
-struct fsxattr {
- __u32 fsx_xflags; /* xflags field value (get/set) */
- __u32 fsx_extsize; /* extsize field value (get/set)*/
- __u32 fsx_nextents; /* nextents field value (get) */
- __u32 fsx_projid; /* project identifier (get/set) */
- unsigned char fsx_pad[12];
-};
-#endif
-
-/*
* Flags for the bs_xflags/fsx_xflags field
* There should be a one-to-one correspondence between these flags and the
* XFS_DIFLAG_s.
@@ -503,8 +490,8 @@ typedef struct xfs_swapext
#define XFS_IOC_ALLOCSP _IOW ('X', 10, struct xfs_flock64)
#define XFS_IOC_FREESP _IOW ('X', 11, struct xfs_flock64)
#define XFS_IOC_DIOINFO _IOR ('X', 30, struct dioattr)
-#define XFS_IOC_FSGETXATTR _IOR ('X', 31, struct fsxattr)
-#define XFS_IOC_FSSETXATTR _IOW ('X', 32, struct fsxattr)
+#define XFS_IOC_FSGETXATTR FS_IOC_FSGETXATTR
+#define XFS_IOC_FSSETXATTR FS_IOC_FSSETXATTR
#define XFS_IOC_ALLOCSP64 _IOW ('X', 36, struct xfs_flock64)
#define XFS_IOC_FREESP64 _IOW ('X', 37, struct xfs_flock64)
#define XFS_IOC_GETBMAP _IOWR('X', 38, struct getbmap)
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 3735fa0..78bcb2b 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -58,6 +58,25 @@ struct inodes_stat_t {
long dummy[5]; /* padding for sysctl ABI compatibility */
};
+/*
+ * Extend attribute flags. These should be or-ed together to figure out what
+ * is valid.
+ */
+#define FSX_XFLAGS (1 << 0)
+#define FSX_EXTSIZE (1 << 1)
+#define FSX_NEXTENTS (1 << 2)
+#define FSX_PROJID (1 << 3)
+
+/*
+ * Structure for FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR.
+ */
+struct fsxattr {
+ __u32 fsx_xflags; /* xflags field value (get/set) */
+ __u32 fsx_extsize; /* extsize field value (get/set)*/
+ __u32 fsx_nextents; /* nextents field value (get) */
+ __u32 fsx_projid; /* project identifier (get/set) */
+ unsigned char fsx_pad[12];
+};
#define NR_FILE 8192 /* this can well be larger on a larger system */
@@ -163,6 +182,8 @@ struct inodes_stat_t {
#define FS_IOC_GETVERSION _IOR('v', 1, long)
#define FS_IOC_SETVERSION _IOW('v', 2, long)
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
+#define FS_IOC_FSGETXATTR _IOR('f', 31, struct fsxattr)
+#define FS_IOC_FSSETXATTR _IOW('f', 32, struct fsxattr)
#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
#define FS_IOC32_GETVERSION _IOR('v', 1, int)
--
1.7.1
^ permalink raw reply related
* [PATCH v5 07/24] amdkfd: Add IOCTL set definitions of amdkfd
From: Oded Gabbay @ 2014-11-08 18:37 UTC (permalink / raw)
To: David Airlie, Alex Deucher, Jerome Glisse
Cc: linux-kernel, dri-devel, John Bridgman, Oded Gabbay, linux-api
In-Reply-To: <1415471865-1893-1-git-send-email-oded.gabbay@amd.com>
- KFD_IOC_GET_VERSION:
Retrieves the interface version of amdkfd
- KFD_IOC_CREATE_QUEUE:
Creates a usermode queue that runs on a specific GPU device
- KFD_IOC_DESTROY_QUEUE:
Destroys an existing usermode queue
- KFD_IOC_SET_MEMORY_POLICY:
Sets the memory policy of the default and alternate aperture of the
calling process
- KFD_IOC_GET_CLOCK_COUNTERS:
Retrieves counters (timestamps) of CPU and GPU
- KFD_IOC_GET_PROCESS_APERTURES:
Retrieves information about process apertures that were initialized
during the open() call of the amdkfd device
- KFD_IOC_UPDATE_QUEUE:
Updates configuration of an existing usermode queue
v3: Remove pragma pack and pmc ioctls. Added parameter for doorbell offset and
a comment on counters
v5:
Add define for AQL queues.
Fix arguments of Get Version IOCTL
Make IOCTL's structures to be the same size on 32/64 bit
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
include/uapi/linux/kfd_ioctl.h | 154 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
create mode 100644 include/uapi/linux/kfd_ioctl.h
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
new file mode 100644
index 0000000..fa1bc6d
--- /dev/null
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef KFD_IOCTL_H_INCLUDED
+#define KFD_IOCTL_H_INCLUDED
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define KFD_IOCTL_MAJOR_VERSION 1
+#define KFD_IOCTL_MINOR_VERSION 2
+
+struct kfd_ioctl_get_version_args {
+ uint32_t major_version; /* from KFD */
+ uint32_t minor_version; /* from KFD */
+};
+
+/* For kfd_ioctl_create_queue_args.queue_type. */
+#define KFD_IOC_QUEUE_TYPE_COMPUTE 0
+#define KFD_IOC_QUEUE_TYPE_SDMA 1
+#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2
+
+#define KFD_MAX_QUEUE_PERCENTAGE 100
+#define KFD_MAX_QUEUE_PRIORITY 15
+
+struct kfd_ioctl_create_queue_args {
+ uint64_t ring_base_address; /* to KFD */
+ uint64_t write_pointer_address; /* from KFD */
+ uint64_t read_pointer_address; /* from KFD */
+ uint64_t doorbell_offset; /* from KFD */
+
+ uint32_t ring_size; /* to KFD */
+ uint32_t gpu_id; /* to KFD */
+ uint32_t queue_type; /* to KFD */
+ uint32_t queue_percentage; /* to KFD */
+ uint32_t queue_priority; /* to KFD */
+ uint32_t queue_id; /* from KFD */
+
+ uint64_t eop_buffer_address; /* to KFD */
+ uint64_t eop_buffer_size; /* to KFD */
+ uint64_t ctx_save_restore_address; /* to KFD */
+ uint64_t ctx_save_restore_size; /* to KFD */
+};
+
+struct kfd_ioctl_destroy_queue_args {
+ uint32_t queue_id; /* to KFD */
+ uint32_t pad;
+};
+
+struct kfd_ioctl_update_queue_args {
+ uint64_t ring_base_address; /* to KFD */
+
+ uint32_t queue_id; /* to KFD */
+ uint32_t ring_size; /* to KFD */
+ uint32_t queue_percentage; /* to KFD */
+ uint32_t queue_priority; /* to KFD */
+};
+
+/* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
+#define KFD_IOC_CACHE_POLICY_COHERENT 0
+#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
+
+struct kfd_ioctl_set_memory_policy_args {
+ uint64_t alternate_aperture_base; /* to KFD */
+ uint64_t alternate_aperture_size; /* to KFD */
+
+ uint32_t gpu_id; /* to KFD */
+ uint32_t default_policy; /* to KFD */
+ uint32_t alternate_policy; /* to KFD */
+ uint32_t pad;
+};
+
+/*
+ * All counters are monotonic. They are used for profiling of compute jobs.
+ * The profiling is done by userspace.
+ *
+ * In case of GPU reset, the counter should not be affected.
+ */
+
+struct kfd_ioctl_get_clock_counters_args {
+ uint64_t gpu_clock_counter; /* from KFD */
+ uint64_t cpu_clock_counter; /* from KFD */
+ uint64_t system_clock_counter; /* from KFD */
+ uint64_t system_clock_freq; /* from KFD */
+
+ uint32_t gpu_id; /* to KFD */
+ uint32_t pad;
+};
+
+#define NUM_OF_SUPPORTED_GPUS 7
+
+struct kfd_process_device_apertures {
+ uint64_t lds_base; /* from KFD */
+ uint64_t lds_limit; /* from KFD */
+ uint64_t scratch_base; /* from KFD */
+ uint64_t scratch_limit; /* from KFD */
+ uint64_t gpuvm_base; /* from KFD */
+ uint64_t gpuvm_limit; /* from KFD */
+ uint32_t gpu_id; /* from KFD */
+ uint32_t pad;
+};
+
+struct kfd_ioctl_get_process_apertures_args {
+ struct kfd_process_device_apertures
+ process_apertures[NUM_OF_SUPPORTED_GPUS];/* from KFD */
+
+ /* from KFD, should be in the range [1 - NUM_OF_SUPPORTED_GPUS] */
+ uint32_t num_of_nodes;
+ uint32_t pad;
+};
+
+#define KFD_IOC_MAGIC 'K'
+
+#define KFD_IOC_GET_VERSION \
+ _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
+
+#define KFD_IOC_CREATE_QUEUE \
+ _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
+
+#define KFD_IOC_DESTROY_QUEUE \
+ _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
+
+#define KFD_IOC_SET_MEMORY_POLICY \
+ _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
+
+#define KFD_IOC_GET_CLOCK_COUNTERS \
+ _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
+
+#define KFD_IOC_GET_PROCESS_APERTURES \
+ _IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args)
+
+#define KFD_IOC_UPDATE_QUEUE \
+ _IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args)
+
+#endif
--
2.1.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox