Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2422645pja; Thu, 26 Mar 2020 15:06:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vujSnCozxSywRVMEK7fn5q9mEWaFz7lAJjlvPnWkNekkKqQdJEYIJN8+TSPd3zWUfBPVCk+ X-Received: by 2002:a05:6830:2147:: with SMTP id r7mr2247239otd.59.1585260406493; Thu, 26 Mar 2020 15:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585260406; cv=none; d=google.com; s=arc-20160816; b=DzLPwv5SO5XPTzXfvohy5bbUB+7LSWe+GOUVoOJY/NFwp5YoYW4g7geDGPkJmz7XUx FCALjpu3ihq3HzaOqdvgt/j7FqMsiWm+lBVJ5A6jSdhzMrgzD4pvI2KhHO7aVy8zRiW8 NhFtstPrFfFYIgtSppGmXRE+1xP+LMcWexkEstjRVJAh5YFKAVT8pPI5QCkkcFfw5PXM 4eklRhrOV+GknMwbMwH7FTHTsGy8km0b4VSD+eL6woMwIJLIHlW2XvE2/T8iTny7QOnD pn4n/AJzJFMYaFxmXHjsebk4tAyEUJDIOr32kx/WclKNd5bOf0iCgJyI7ubzJsDaofvL KqSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=eXMKLFOuig/lrxP0VVUXkgc9/EArNxSzfnhMuffijjs=; b=lJq0m9Y7ANo/9K9W4vV+TyTmd/cnsid5fMKI64isAt6GxOasS/ilzKp6mo2Ng/SVu+ KZMdvhi29acJXGX4FurWmj9RJtbgxHogRmUm2W2RpBOD4W4J2z7dzo+kvYljEItx1E09 Wp9DHWxXPgg/Js3/YWD/c7pEEU8O2PWSULEe/H8YY/MBqAW5BiZ8OsKvpZxinLQ7ymK5 5iL7InNjT8O9V2n7WpQvf2R//9LoY1BGeRxiQJpCeTuQgRe5gXbjCVOLnbbhE41Gdsq6 Cgt3WzYCS6JZBqwaZXgz2E1EG5sLYuqNOX4jC83tsYLDFTT2nk+eUZvT4OwGJZgmZjuT p35w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=V6ann6Qc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si1604923otp.254.2020.03.26.15.06.33; Thu, 26 Mar 2020 15:06:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=V6ann6Qc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726270AbgCZWGM (ORCPT + 99 others); Thu, 26 Mar 2020 18:06:12 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:42756 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbgCZWGM (ORCPT ); Thu, 26 Mar 2020 18:06:12 -0400 Received: by mail-io1-f68.google.com with SMTP id q128so7777297iof.9 for ; Thu, 26 Mar 2020 15:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=eXMKLFOuig/lrxP0VVUXkgc9/EArNxSzfnhMuffijjs=; b=V6ann6QcT5OZrlVlQ0m0HfuOpK+HG2vAx0XRSxqnqYUZAFEPnOdrYGOHu9JYcYM2JO X/qOaM/Gx+gE/Nqog3CUZS7+XCufCbSbYGRq9Pa0vyuMCmWi8fNWSyzgokLTsSCDtRAq KYwWzyi94K8pM32rWZTtD7jK4LxEB+3yn73lI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=eXMKLFOuig/lrxP0VVUXkgc9/EArNxSzfnhMuffijjs=; b=GiRuZzklk38haNoc+NeS5wkQWAFHunO5xKiKR0qojZoEJ7GPeO1z9LQ2A7sfDn9NuF IcM9XxDjEQ4IBJO30SpSPg2VTGwbQfqe6kMWlm+11bpvQ/19iJ9T6YkLXTZMe8kO8lsX aPAKiENiKP1ctpoo/5O3BMvycleK5q6yVgPIDOX9nYLDjzCmLuGyndBzZihxcNACbX2h 7H9gtsiYpJJzT4/ETu62b80fxWmLNCgXfpf6ZEkNkAcslqBJiPZr2NX/I2gi4UrYPje0 wnZs/123s+OLPv9oZ/01CPcpebuGD+gIwaLeHAN688kL5rsQOLanG6vJ8GZsW/QozVGl lTcw== X-Gm-Message-State: ANhLgQ1w1QS3Q6T+nZQFq5a9o+bXvJOjY28B0Un+7i0z5FQkPb3OYy3W 4PJEhE9DH1czzh1274pC2Z4VZVISDvA= X-Received: by 2002:a02:2a4a:: with SMTP id w71mr10005605jaw.75.1585260370579; Thu, 26 Mar 2020 15:06:10 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id u5sm942481ion.51.2020.03.26.15.06.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2020 15:06:10 -0700 (PDT) Subject: Re: [PATCH v2 3/3] media: vimc: deb: Add support for {RGB,BGR,GBR}888 bus formats on source pad To: =?UTF-8?B?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , linux-media@vger.kernel.org Cc: Helen Koike , Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org, Shuah Khan References: <20200326214730.2449707-1-nfraprado@protonmail.com> <20200326214730.2449707-4-nfraprado@protonmail.com> From: Shuah Khan Message-ID: Date: Thu, 26 Mar 2020 16:06:08 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200326214730.2449707-4-nfraprado@protonmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/26/20 3:47 PM, NĂ­colas F. R. A. Prado wrote: > Add support for RGB888_*, BGR888_* and GBR888_* media bus formats on > the source pad of debayer subdevices. > > Co-developed-by: Vitor Massaru Iha > Signed-off-by: Vitor Massaru Iha > Signed-off-by: NĂ­colas F. R. A. Prado > --- > > Changes in v2: > - Change commit message to reflect v2 changes > - Rename variables > - Fix array formatting > - Add vimc_deb_is_src_code_valid function > - Add other BGR888 and RGB888 formats to debayer source pad supported > formats > > drivers/media/platform/vimc/vimc-debayer.c | 61 +++++++++++++++++----- > 1 file changed, 49 insertions(+), 12 deletions(-) > > diff --git a/drivers/media/platform/vimc/vimc-debayer.c b/drivers/media/platform/vimc/vimc-debayer.c > index baf6bf9f65b5..33a9bea770bc 100644 > --- a/drivers/media/platform/vimc/vimc-debayer.c > +++ b/drivers/media/platform/vimc/vimc-debayer.c > @@ -51,6 +51,19 @@ static const struct v4l2_mbus_framefmt sink_fmt_default = { > .colorspace = V4L2_COLORSPACE_DEFAULT, > }; > > +static const u32 vimc_deb_src_mbus_codes[] = { > + MEDIA_BUS_FMT_GBR888_1X24, > + MEDIA_BUS_FMT_BGR888_1X24, > + MEDIA_BUS_FMT_BGR888_3X8, > + MEDIA_BUS_FMT_RGB888_1X24, > + MEDIA_BUS_FMT_RGB888_2X12_BE, > + MEDIA_BUS_FMT_RGB888_2X12_LE, > + MEDIA_BUS_FMT_RGB888_3X8, > + MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, > + MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, > + MEDIA_BUS_FMT_RGB888_1X32_PADHI, > +}; > + > static const struct vimc_deb_pix_map vimc_deb_pix_map_list[] = { > { > .code = MEDIA_BUS_FMT_SBGGR8_1X8, > @@ -125,6 +138,17 @@ static const struct vimc_deb_pix_map *vimc_deb_pix_map_by_code(u32 code) > return NULL; > } > > +static int vimc_deb_is_src_code_invalid(u32 code) > +{ > + unsigned int i; > + > + for (i = 0; i < ARRAY_SIZE(vimc_deb_src_mbus_codes); i++) > + if (vimc_deb_src_mbus_codes[i] == code) > + return 0; > + > + return -EINVAL; > +} > + > static int vimc_deb_init_cfg(struct v4l2_subdev *sd, > struct v4l2_subdev_pad_config *cfg) > { > @@ -148,14 +172,11 @@ static int vimc_deb_enum_mbus_code(struct v4l2_subdev *sd, > struct v4l2_subdev_pad_config *cfg, > struct v4l2_subdev_mbus_code_enum *code) > { > - /* We only support one format for source pads */ > if (VIMC_IS_SRC(code->pad)) { > - struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); > - > - if (code->index) > + if (code->index >= ARRAY_SIZE(vimc_deb_src_mbus_codes)) > return -EINVAL; > > - code->code = vdeb->src_code; > + code->code = vimc_deb_src_mbus_codes[code->index]; > } else { > if (code->index >= ARRAY_SIZE(vimc_deb_pix_map_list)) > return -EINVAL; > @@ -170,8 +191,6 @@ static int vimc_deb_enum_frame_size(struct v4l2_subdev *sd, > struct v4l2_subdev_pad_config *cfg, > struct v4l2_subdev_frame_size_enum *fse) > { > - struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); > - > if (fse->index) > return -EINVAL; > > @@ -181,7 +200,7 @@ static int vimc_deb_enum_frame_size(struct v4l2_subdev *sd, > > if (!vpix) > return -EINVAL; > - } else if (fse->code != vdeb->src_code) { > + } else if (vimc_deb_is_src_code_invalid(fse->code)) { > return -EINVAL; > } > > @@ -237,6 +256,7 @@ static int vimc_deb_set_fmt(struct v4l2_subdev *sd, > { > struct vimc_deb_device *vdeb = v4l2_get_subdevdata(sd); > struct v4l2_mbus_framefmt *sink_fmt; > + u32 *src_code; > > if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { > /* Do not change the format while stream is on */ > @@ -244,8 +264,10 @@ static int vimc_deb_set_fmt(struct v4l2_subdev *sd, > return -EBUSY; > > sink_fmt = &vdeb->sink_fmt; > + src_code = &vdeb->src_code; > } else { > sink_fmt = v4l2_subdev_get_try_format(sd, cfg, 0); > + src_code = &v4l2_subdev_get_try_format(sd, cfg, 1)->code; > } > > /* > @@ -253,9 +275,14 @@ static int vimc_deb_set_fmt(struct v4l2_subdev *sd, > * it is propagated from the sink > */ > if (VIMC_IS_SRC(fmt->pad)) { > + u32 code = fmt->format.code; > + > fmt->format = *sink_fmt; > - /* TODO: Add support for other formats */ > - fmt->format.code = vdeb->src_code; > + > + if (!vimc_deb_is_src_code_invalid(code)) > + *src_code = code; > + > + fmt->format.code = *src_code; > } else { > /* Set the new format in the sink pad */ > vimc_deb_adjust_sink_fmt(&fmt->format); > @@ -291,11 +318,21 @@ static void vimc_deb_set_rgb_mbus_fmt_rgb888_1x24(struct vimc_deb_device *vdeb, > unsigned int col, > unsigned int rgb[3]) Change this to pass a pointer and size. > { > + const struct vimc_pix_map *vpix; > unsigned int i, index; > > + vpix = vimc_pix_map_by_code(vdeb->src_code); > index = VIMC_FRAME_INDEX(lin, col, vdeb->sink_fmt.width, 3); > - for (i = 0; i < 3; i++) > - vdeb->src_frame[index + i] = rgb[i]; > + for (i = 0; i < 3; i++) { > + switch (vpix->pixelformat) { > + case V4L2_PIX_FMT_RGB24: > + vdeb->src_frame[index + i] = rgb[i]; > + break; > + case V4L2_PIX_FMT_BGR24: > + vdeb->src_frame[index + i] = rgb[2-i]; > + break; > + } > + } > } > > static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable) > thanks, -- Shuah