Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752451AbaKGMVS (ORCPT ); Fri, 7 Nov 2014 07:21:18 -0500 Received: from down.free-electrons.com ([37.187.137.238]:58046 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752285AbaKGMVN (ORCPT ); Fri, 7 Nov 2014 07:21:13 -0500 Date: Fri, 7 Nov 2014 13:21:08 +0100 From: Boris Brezillon To: Sakari Ailus Cc: Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-api@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Guennadi Liakhovetski Subject: Re: [PATCH v2 01/10] [media] Move mediabus format definition to a more standard place Message-ID: <20141107132108.0f30dafb@bbrezillon> In-Reply-To: <20141107114358.GB3136@valkosipuli.retiisi.org.uk> References: <1415267829-4177-1-git-send-email-boris.brezillon@free-electrons.com> <1415267829-4177-2-git-send-email-boris.brezillon@free-electrons.com> <20141107114358.GB3136@valkosipuli.retiisi.org.uk> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 Nov 2014 13:43:59 +0200 Sakari Ailus wrote: > Hi Boris, > > Thank you for the update. > > On Thu, Nov 06, 2014 at 10:56:59AM +0100, Boris Brezillon wrote: > > Rename mediabus formats and move the enum into a separate header file so > > that it can be used by DRM/KMS subsystem without any reference to the V4L2 > > subsystem. > > > > Old v4l2_mbus_pixelcode now points to media_bus_format. > > > > Signed-off-by: Boris Brezillon > > Acked-by: Guennadi Liakhovetski > > --- > > include/uapi/linux/Kbuild | 1 + > > include/uapi/linux/media-bus-format.h | 131 ++++++++++++++++++++++++++++++++++ > > include/uapi/linux/v4l2-mediabus.h | 114 +---------------------------- > > 3 files changed, 134 insertions(+), 112 deletions(-) > > create mode 100644 include/uapi/linux/media-bus-format.h > > > > diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild > > index b70237e..b2c23f8 100644 > > --- a/include/uapi/linux/Kbuild > > +++ b/include/uapi/linux/Kbuild > > @@ -414,6 +414,7 @@ header-y += veth.h > > header-y += vfio.h > > header-y += vhost.h > > header-y += videodev2.h > > +header-y += media-bus-format.h > > Could you arrange this to the list alphabetically, please? > > > header-y += virtio_9p.h > > header-y += virtio_balloon.h > > header-y += virtio_blk.h > > diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h > > new file mode 100644 > > index 0000000..251a902 > > --- /dev/null > > +++ b/include/uapi/linux/media-bus-format.h > > @@ -0,0 +1,131 @@ > > +/* > > + * Media Bus API header > > + * > > + * Copyright (C) 2009, Guennadi Liakhovetski > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2 as > > + * published by the Free Software Foundation. > > + */ > > + > > +#ifndef __LINUX_MEDIA_BUS_FORMAT_H > > +#define __LINUX_MEDIA_BUS_FORMAT_H > > + > > +/* > > + * These bus formats uniquely identify data formats on the data bus. Format 0 > > + * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where > > + * the data format is fixed. Additionally, "2X8" means that one pixel is > > + * transferred in two 8-bit samples, "BE" or "LE" specify in which order those > > + * samples are transferred over the bus: "LE" means that the least significant > > + * bits are transferred first, "BE" means that the most significant bits are > > + * transferred first, and "PADHI" and "PADLO" define which bits - low or high, > > + * in the incomplete high byte, are filled with padding bits. > > + * > > + * The bus formats are grouped by type, bus_width, bits per component, samples > > + * per pixel and order of subsamples. Numerical values are sorted using generic > > + * numerical sort order (8 thus comes before 10). > > + * > > + * As their value can't change when a new bus format is inserted in the > > + * enumeration, the bus formats are explicitly given a numerical value. The next > > + * free values for each category are listed below, update them when inserting > > + * new pixel codes. > > + */ > > + > > +#define MEDIA_BUS_FMT_ENTRY(name, val) \ > > + MEDIA_BUS_FMT_ ## name = val, \ > > + V4L2_MBUS_FMT_ ## name = val > > + > > +enum media_bus_format { > > There's no really a need to keep the definitions inside the enum. It looks a > little bit confusing to me. That made me realise something I missed > yesterday. > > There's a difference: the enum in C++ is a different thing than in C, and > the enum type isn't able to contain any other values than those defined in > the enumeration. > > So what I propose is the following. Keep enum v4l2_mbus_pixelcode around, > including the enum values. Define new values for MEDIA_BUS_* equivalents > using preprocessor macros, as you've done below. Drop the definition of enum > media_bus_format, and use u32 (or uint32_t) type for the variables. > > This way the enum stays intact for existing C++ applications, and new > applications will have to use a 32-bit type. > Fair enough. If Hans agree I'll rework the series and drop the media_bus_format enum. Thanks, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/