From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A584EC43381 for ; Thu, 21 Mar 2019 04:07:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56834218A5 for ; Thu, 21 Mar 2019 04:07:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WlVj06WL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725983AbfCUEHK (ORCPT ); Thu, 21 Mar 2019 00:07:10 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:34964 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbfCUEHK (ORCPT ); Thu, 21 Mar 2019 00:07:10 -0400 Received: by mail-ot1-f67.google.com with SMTP id h7so4305031otm.2 for ; Wed, 20 Mar 2019 21:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kB7bECJuohRjhZCdmLp9SMfR5l8Aw2pJfOx9kmofFPw=; b=WlVj06WLMsppNRSoOjg3qZTXg0sJX/EwpaXZ6fHRjp06ks6wHZ2RwhnCnWDUBCizPW HclVyM92KReeY/Dl1vubN6w1LGUOi6JlcF2MDpzJkbPS4hN97nJ1bIZCD9QrSNBUuaC9 Ap89ZKUoP9v/craH3BCzOT9JWsYiy5cB/ENzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kB7bECJuohRjhZCdmLp9SMfR5l8Aw2pJfOx9kmofFPw=; b=uHknrK077YlnP1tDDJkWe7GqfbJY+NNRjkLPwPUw9DK0lmB6D7Z7BVPSxdoZ3C9rsv b91mu7RF0MfCdNjVLC512CeHrdthZNbLmVWsZ1ZuQfNBRuARivrqlsLfBGBBI+E5vCk+ xnNXdNj0ZigStWcTIe6YnrPB548jZB4HsdbPGo2JQtJKJe8XJp8dbKsvoYLHCmNTx4EQ E4gQUmIr6EyaIAdN17lV3VfWia/5dSDI33/v+jPXogLiTTY9/pI4ATAGzI5d7MLlthlr 7KMfQbDJXANIOcMmYeKhxdo+BxkfTZx6O+uVS725j3NmwxEAeuoFfTpzXCvTyoaql6TA ErdQ== X-Gm-Message-State: APjAAAUh0giEen2xUG7EjOhXQE9ckvHLXqid5TStsnbzDxdREKcLL51z R3+d1mQC0huwwAyv5ykVQmXpWxcXTAA= X-Google-Smtp-Source: APXvYqwPBYOBoIPLmIXfmo8X6nrk9OkGQCvhOG9NycZcYKXMg761SVRrhqvfDMEQ8L80FCLm7En8SQ== X-Received: by 2002:a9d:6505:: with SMTP id i5mr1140390otl.263.1553141228768; Wed, 20 Mar 2019 21:07:08 -0700 (PDT) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com. [209.85.167.177]) by smtp.gmail.com with ESMTPSA id h26sm1535010otm.48.2019.03.20.21.07.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 21:07:08 -0700 (PDT) Received: by mail-oi1-f177.google.com with SMTP id w137so3679876oiw.5 for ; Wed, 20 Mar 2019 21:07:08 -0700 (PDT) X-Received: by 2002:aca:4b03:: with SMTP id y3mr884884oia.21.1553140792562; Wed, 20 Mar 2019 20:59:52 -0700 (PDT) MIME-Version: 1.0 References: <1549348966-14451-1-git-send-email-frederic.chen@mediatek.com> <1549348966-14451-8-git-send-email-frederic.chen@mediatek.com> <1552460044.13953.114.camel@mtksdccf07> In-Reply-To: <1552460044.13953.114.camel@mtksdccf07> From: Tomasz Figa Date: Thu, 21 Mar 2019 12:59:41 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH V0 7/7] [media] platform: mtk-isp: Add Mediatek ISP Pass 1 driver To: Jungo Lin Cc: Frederic Chen , =?UTF-8?B?U2VhbiBDaGVuZyAo6YSt5piH5byYKQ==?= , Laurent Pinchart , =?UTF-8?B?UnlubiBXdSAo5ZCz6IKy5oGpKQ==?= , =?UTF-8?B?Q2hyaXN0aWUgWXUgKOa4uOmbheaDoCk=?= , srv_heupstream@mediatek.com, =?UTF-8?B?SG9sbWVzIENoaW91ICjpgrHmjLop?= , Jerry-ch Chen , Sj Huang , yuzhao@chromium.org, linux-mediatek@lists.infradead.org, zwisler@chromium.org, Matthias Brugger , Hans Verkuil , Mauro Carvalho Chehab , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Linux Media Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On Wed, Mar 13, 2019 at 3:54 PM Jungo Lin wrote: > > On Tue, 2019-03-12 at 19:04 +0900, Tomasz Figa wrote: [snip] > > Instead of opencoding most of this function, one would normally call > > mtk_cam_videoc_try_fmt() first to adjust the format struct and then > > just update the driver state with the adjusted format. > > > > Also, similarly to VIDIOC_TRY_FMT, VIDIOC_SET_FMT doesn't fail unless > > in the very specific cases, as described in > > https://www.kernel.org/doc/html/latest/media/uapi/v4l/vidioc-g-fmt.html#return-value > > . > > > > Ok, below is our revised version of this function. > > int mtk_cam_videoc_s_fmt(struct file *file, void *fh, > struct v4l2_format *f) > { > struct mtk_cam_mem2mem2_device *m2m2 = video_drvdata(file); > struct mtk_cam_dev *cam_dev = mtk_cam_m2m_to_dev(m2m2); > struct mtk_cam_video_device *node = file_to_mtk_cam_node(file); > > /* Get the valid format*/ > mtk_cam_videoc_try_fmt(file, fh, f); > /* Configure to video device */ > mtk_cam_ctx_fmt_set_img(&cam_dev->pdev->dev, > &node->vdev_fmt.fmt.pix_mp, > &f->fmt.pix_mp, > node->queue_id); > > return 0; > } > Looks almost good. We still need to signal the -EBUSY error condition if an attempt to change the format is made while streaming is active. [snip] > > > +static int mtk_cam_videoc_s_meta_fmt(struct file *file, > > > + void *fh, struct v4l2_format *f) > > > +{ > > > + struct mtk_cam_mem2mem2_device *m2m2 = video_drvdata(file); > > > + struct mtk_cam_dev *isp_dev = mtk_cam_m2m_to_dev(m2m2); > > > + struct mtk_cam_ctx *dev_ctx = &isp_dev->ctx; > > > + struct mtk_cam_dev_video_device *node = file_to_mtk_cam_node(file); > > > + int queue_id = mtk_cam_dev_get_queue_id_of_dev_node(isp_dev, node); > > > + > > > > No need for this blank line. > > > > We will fix this coding style in next patch. > > > > + int ret = 0; > > > > Please don't default-initialize without a good reason. > > > > Ok, fix in next patch. > > > > + > > > + if (f->type != node->vbq.type) > > > + return -EINVAL; > > > > Ditto. > > > > Ok, fix in next patch. > > > > + > > > + ret = mtk_cam_ctx_format_load_default_fmt(&dev_ctx->queue[queue_id], f); > > > + > > > > No need for this blank line. > > > > Ok, fix in next patch. > > > > + if (!ret) { > > > + node->vdev_fmt.fmt.meta = f->fmt.meta; > > > + dev_ctx->queue[queue_id].fmt.meta = node->vdev_fmt.fmt.meta; > > > + } else { > > > + dev_warn(&isp_dev->pdev->dev, > > > + "s_meta_fm failed, format not support\n"); > > > > No need for this warning. > > > > Ok, fix in next patch. > > > > + } > > > + > > > + return ret; > > > +} > > > > Actually, why do we even need to do all the things? Do we support > > multiple different meta formats on the same video node? If not, we can > > just have all the TRY_FMT/S_FMT/G_FMT return the hardcoded format. > > > > Ok, it is a good idea. We will return the hardcode format for meta video > devices. > Below is the revision version. > > int mtk_cam_meta_enum_format(struct file *file, > void *fh, struct v4l2_fmtdesc *f) > { > struct mtk_cam_video_device *node = file_to_mtk_cam_node(file); > > f->pixelformat = node->vdev_fmt.fmt.meta.dataformat; > > return 0; > } Need to error out if f->index > 0. Also need to initialize the other output fields - flags and description. [snip] > > > +static u32 mtk_cam_node_get_v4l2_cap(struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + u32 cap = 0; > > > + > > > + if (node_ctx->desc.capture) > > > + if (node_ctx->desc.image) > > > + cap = V4L2_CAP_VIDEO_CAPTURE_MPLANE; > > > + else > > > + cap = V4L2_CAP_META_CAPTURE; > > > + else > > > + if (node_ctx->desc.image) > > > + cap = V4L2_CAP_VIDEO_OUTPUT_MPLANE; > > > + else > > > + cap = V4L2_CAP_META_OUTPUT; > > > + > > > + return cap; > > > +} > > > > Why not just have this defined statically as node_ctx->desc.cap? > > > > Ok, it is refactoring done. > > > > + > > > +static u32 mtk_cam_node_get_format_type(struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + u32 type; > > > + > > > + if (node_ctx->desc.capture) > > > + if (node_ctx->desc.image) > > > + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; > > > + else > > > + type = V4L2_BUF_TYPE_META_CAPTURE; > > > + else > > > + if (node_ctx->desc.image) > > > + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; > > > + else > > > + type = V4L2_BUF_TYPE_META_OUTPUT; > > > + > > > + return type; > > > +} > > > > Why not just have this defined statically as node_ctx->desc.buf_type? > > > > Same as above. > > > > + > > > +static const struct v4l2_ioctl_ops *mtk_cam_node_get_ioctl_ops > > > + (struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + const struct v4l2_ioctl_ops *ops = NULL; > > > + > > > + if (node_ctx->desc.image) > > > + ops = &mtk_cam_v4l2_ioctl_ops; > > > + else > > > + ops = &mtk_cam_v4l2_meta_ioctl_ops; > > > + return ops; > > > +} > > > > It's also preferable to just put this inside some structure rather > > than have getter functions. (node_ctx->desc.ioctl_ops?) > > > > Same as above. > Below is the new version for struct mtk_cam_ctx_queue_desc > > /* > * struct mtk_cam_ctx_queue_desc - queue attributes > * setup by device context owner > * @id: id of the context queue > * @name: media entity name > * @cap: mapped to V4L2 capabilities > * @buf_type: mapped to V4L2 buffer type > * @capture: true for capture queue (device to user) > * false for output queue (from user to device) > * @image: true for image, false for meta data > * @smem_alloc: Using the cam_smem_drv as alloc ctx or not > * @dma_port: the dma port associated to the buffer > * @fmts: supported format > * @num_fmts: the number of supported formats > * @default_fmt_idx: default format of this queue > * @max_buf_count: maximum V4L2 buffer count > * @max_buf_count: mapped to v4l2_ioctl_ops > */ > struct mtk_cam_ctx_queue_desc { > u8 id; > char *name; > u32 cap; > u32 buf_type; > u32 dma_port; > u32 smem_alloc:1; > u8 capture:1; > u8 image:1; > u8 num_fmts; > u8 default_fmt_idx; > u8 max_buf_count; > const struct v4l2_ioctl_ops *ioctl_ops; > struct v4l2_format *fmts; > }; SGTM +/- the missing kerneldoc for the new fields. [snip] > > Sorry, ran out of time for today. Fourth part will come. :) > > > > Best regards, > > Tomasz > > > > Appreciate your support and hard working on this review. > We will look forward your part 4 review. Thanks for replying to all the comments, it's very helpful. As I mentioned in another reply, I'm going to be busy for the next few days, so I'd suggest addressing the existing comments, fixing any v4l2-compliance issues and also checking if any changes could be applied to the other drivers (DIP, FD, Seninf, MDP) too and then sending RFC V1. Best regards, Tomasz From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Figa Subject: Re: [RFC PATCH V0 7/7] [media] platform: mtk-isp: Add Mediatek ISP Pass 1 driver Date: Thu, 21 Mar 2019 12:59:41 +0900 Message-ID: References: <1549348966-14451-1-git-send-email-frederic.chen@mediatek.com> <1549348966-14451-8-git-send-email-frederic.chen@mediatek.com> <1552460044.13953.114.camel@mtksdccf07> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1552460044.13953.114.camel@mtksdccf07> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Jungo Lin Cc: =?UTF-8?B?U2VhbiBDaGVuZyAo6YSt5piH5byYKQ==?= , Laurent Pinchart , =?UTF-8?B?UnlubiBXdSAo5ZCz6IKy5oGpKQ==?= , srv_heupstream@mediatek.com, Mauro Carvalho Chehab , =?UTF-8?B?SG9sbWVzIENoaW91ICjpgrHmjLop?= , Jerry-ch Chen , Sj Huang , yuzhao@chromium.org, =?UTF-8?B?Q2hyaXN0aWUgWXUgKOa4uOmbheaDoCk=?= , zwisler@chromium.org, Matthias Brugger , linux-mediatek@lists.infradead.org, Frederic Chen , Hans Verkuil , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , Linux Media Mailing List List-Id: linux-mediatek@lists.infradead.org On Wed, Mar 13, 2019 at 3:54 PM Jungo Lin wrote: > > On Tue, 2019-03-12 at 19:04 +0900, Tomasz Figa wrote: [snip] > > Instead of opencoding most of this function, one would normally call > > mtk_cam_videoc_try_fmt() first to adjust the format struct and then > > just update the driver state with the adjusted format. > > > > Also, similarly to VIDIOC_TRY_FMT, VIDIOC_SET_FMT doesn't fail unless > > in the very specific cases, as described in > > https://www.kernel.org/doc/html/latest/media/uapi/v4l/vidioc-g-fmt.html#return-value > > . > > > > Ok, below is our revised version of this function. > > int mtk_cam_videoc_s_fmt(struct file *file, void *fh, > struct v4l2_format *f) > { > struct mtk_cam_mem2mem2_device *m2m2 = video_drvdata(file); > struct mtk_cam_dev *cam_dev = mtk_cam_m2m_to_dev(m2m2); > struct mtk_cam_video_device *node = file_to_mtk_cam_node(file); > > /* Get the valid format*/ > mtk_cam_videoc_try_fmt(file, fh, f); > /* Configure to video device */ > mtk_cam_ctx_fmt_set_img(&cam_dev->pdev->dev, > &node->vdev_fmt.fmt.pix_mp, > &f->fmt.pix_mp, > node->queue_id); > > return 0; > } > Looks almost good. We still need to signal the -EBUSY error condition if an attempt to change the format is made while streaming is active. [snip] > > > +static int mtk_cam_videoc_s_meta_fmt(struct file *file, > > > + void *fh, struct v4l2_format *f) > > > +{ > > > + struct mtk_cam_mem2mem2_device *m2m2 = video_drvdata(file); > > > + struct mtk_cam_dev *isp_dev = mtk_cam_m2m_to_dev(m2m2); > > > + struct mtk_cam_ctx *dev_ctx = &isp_dev->ctx; > > > + struct mtk_cam_dev_video_device *node = file_to_mtk_cam_node(file); > > > + int queue_id = mtk_cam_dev_get_queue_id_of_dev_node(isp_dev, node); > > > + > > > > No need for this blank line. > > > > We will fix this coding style in next patch. > > > > + int ret = 0; > > > > Please don't default-initialize without a good reason. > > > > Ok, fix in next patch. > > > > + > > > + if (f->type != node->vbq.type) > > > + return -EINVAL; > > > > Ditto. > > > > Ok, fix in next patch. > > > > + > > > + ret = mtk_cam_ctx_format_load_default_fmt(&dev_ctx->queue[queue_id], f); > > > + > > > > No need for this blank line. > > > > Ok, fix in next patch. > > > > + if (!ret) { > > > + node->vdev_fmt.fmt.meta = f->fmt.meta; > > > + dev_ctx->queue[queue_id].fmt.meta = node->vdev_fmt.fmt.meta; > > > + } else { > > > + dev_warn(&isp_dev->pdev->dev, > > > + "s_meta_fm failed, format not support\n"); > > > > No need for this warning. > > > > Ok, fix in next patch. > > > > + } > > > + > > > + return ret; > > > +} > > > > Actually, why do we even need to do all the things? Do we support > > multiple different meta formats on the same video node? If not, we can > > just have all the TRY_FMT/S_FMT/G_FMT return the hardcoded format. > > > > Ok, it is a good idea. We will return the hardcode format for meta video > devices. > Below is the revision version. > > int mtk_cam_meta_enum_format(struct file *file, > void *fh, struct v4l2_fmtdesc *f) > { > struct mtk_cam_video_device *node = file_to_mtk_cam_node(file); > > f->pixelformat = node->vdev_fmt.fmt.meta.dataformat; > > return 0; > } Need to error out if f->index > 0. Also need to initialize the other output fields - flags and description. [snip] > > > +static u32 mtk_cam_node_get_v4l2_cap(struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + u32 cap = 0; > > > + > > > + if (node_ctx->desc.capture) > > > + if (node_ctx->desc.image) > > > + cap = V4L2_CAP_VIDEO_CAPTURE_MPLANE; > > > + else > > > + cap = V4L2_CAP_META_CAPTURE; > > > + else > > > + if (node_ctx->desc.image) > > > + cap = V4L2_CAP_VIDEO_OUTPUT_MPLANE; > > > + else > > > + cap = V4L2_CAP_META_OUTPUT; > > > + > > > + return cap; > > > +} > > > > Why not just have this defined statically as node_ctx->desc.cap? > > > > Ok, it is refactoring done. > > > > + > > > +static u32 mtk_cam_node_get_format_type(struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + u32 type; > > > + > > > + if (node_ctx->desc.capture) > > > + if (node_ctx->desc.image) > > > + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; > > > + else > > > + type = V4L2_BUF_TYPE_META_CAPTURE; > > > + else > > > + if (node_ctx->desc.image) > > > + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; > > > + else > > > + type = V4L2_BUF_TYPE_META_OUTPUT; > > > + > > > + return type; > > > +} > > > > Why not just have this defined statically as node_ctx->desc.buf_type? > > > > Same as above. > > > > + > > > +static const struct v4l2_ioctl_ops *mtk_cam_node_get_ioctl_ops > > > + (struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + const struct v4l2_ioctl_ops *ops = NULL; > > > + > > > + if (node_ctx->desc.image) > > > + ops = &mtk_cam_v4l2_ioctl_ops; > > > + else > > > + ops = &mtk_cam_v4l2_meta_ioctl_ops; > > > + return ops; > > > +} > > > > It's also preferable to just put this inside some structure rather > > than have getter functions. (node_ctx->desc.ioctl_ops?) > > > > Same as above. > Below is the new version for struct mtk_cam_ctx_queue_desc > > /* > * struct mtk_cam_ctx_queue_desc - queue attributes > * setup by device context owner > * @id: id of the context queue > * @name: media entity name > * @cap: mapped to V4L2 capabilities > * @buf_type: mapped to V4L2 buffer type > * @capture: true for capture queue (device to user) > * false for output queue (from user to device) > * @image: true for image, false for meta data > * @smem_alloc: Using the cam_smem_drv as alloc ctx or not > * @dma_port: the dma port associated to the buffer > * @fmts: supported format > * @num_fmts: the number of supported formats > * @default_fmt_idx: default format of this queue > * @max_buf_count: maximum V4L2 buffer count > * @max_buf_count: mapped to v4l2_ioctl_ops > */ > struct mtk_cam_ctx_queue_desc { > u8 id; > char *name; > u32 cap; > u32 buf_type; > u32 dma_port; > u32 smem_alloc:1; > u8 capture:1; > u8 image:1; > u8 num_fmts; > u8 default_fmt_idx; > u8 max_buf_count; > const struct v4l2_ioctl_ops *ioctl_ops; > struct v4l2_format *fmts; > }; SGTM +/- the missing kerneldoc for the new fields. [snip] > > Sorry, ran out of time for today. Fourth part will come. :) > > > > Best regards, > > Tomasz > > > > Appreciate your support and hard working on this review. > We will look forward your part 4 review. Thanks for replying to all the comments, it's very helpful. As I mentioned in another reply, I'm going to be busy for the next few days, so I'd suggest addressing the existing comments, fixing any v4l2-compliance issues and also checking if any changes could be applied to the other drivers (DIP, FD, Seninf, MDP) too and then sending RFC V1. Best regards, Tomasz From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B8D1C43381 for ; Thu, 21 Mar 2019 04:00:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3DA9218A5 for ; Thu, 21 Mar 2019 04:00:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="f0C1Zwa/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WlVj06WL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3DA9218A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zB7jtc0PgAognITO6ESEU8YrvoIRNBJKcOXMhjwS32Q=; b=f0C1Zwa/HAe921 L2PfQPFqCvLEPfqqTjmkLDiNXATcNWnumdSk3ZLixF86V2l2Eig6LdxDncFg363LsAtxVISk19VZy c+krP8ZHrcjpab1nA/g7VhJ0Fgn+VTed5k0gBHOS0a+YF6ExFPN1MVqHu3EHz6rw4KI0D9gy5IbQN JiPXADDxQ2G7sB7wWy7rPfVbrSPnW82fxZ7tZ3398ciUuqKWkpbNR0uQcVA2Nk6Dz8VBNjFp6SzPD SkGJsiBDa+EhwVbpf8qQpccgokbJeh1iMBMcXNQ3Z2lHyRsHKYLTPS4sOCzjn0j6fd780RYkn9aAX QY5LOSfz1cPH8uTEKZUA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6os9-0001jR-1c; Thu, 21 Mar 2019 04:00:05 +0000 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6os4-0001MN-Bh for linux-arm-kernel@lists.infradead.org; Thu, 21 Mar 2019 04:00:02 +0000 Received: by mail-oi1-x243.google.com with SMTP id e22so3680622oiy.0 for ; Wed, 20 Mar 2019 20:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kB7bECJuohRjhZCdmLp9SMfR5l8Aw2pJfOx9kmofFPw=; b=WlVj06WLMsppNRSoOjg3qZTXg0sJX/EwpaXZ6fHRjp06ks6wHZ2RwhnCnWDUBCizPW HclVyM92KReeY/Dl1vubN6w1LGUOi6JlcF2MDpzJkbPS4hN97nJ1bIZCD9QrSNBUuaC9 Ap89ZKUoP9v/craH3BCzOT9JWsYiy5cB/ENzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kB7bECJuohRjhZCdmLp9SMfR5l8Aw2pJfOx9kmofFPw=; b=QcjGa2CV70b/w78qJlcGTBdMQfFwaCL9VqpJAwdUEJEroL+PusDArW0PXU+cKqlTHr Q1K/HFC+PeQDKs3RHX6mxs4vDkBrdLJM5Mw1ani3AspkQfvJdq1fSVTrbkeFJiexqx+X dVlIwn2RsWQz6RYDtAe65w4tK/Ue2a5ud0CNDN7RSUauZ3Day2alThjNILYqZHK6IOFZ zhxPtP7LaBIlH5QnQ3Jx50nxzyQIukWVx/hN29CpqzTjxgTT2cpAuWcCTs+BU1gfLA5O LTXbhtybrsB6suixfOSeJ5+LRtUkLH1zt8W3FZ564IPCNrZH8XsFuk/48Hlyk19S7Jt7 pLxA== X-Gm-Message-State: APjAAAUWDzjGNTFUgx+SDVKJJ8omRGspkTwk9oaWRJaCF4fpHWO8ONuz nW7OmCqiKaJk9wNdO+aRC9CQNjShwpI= X-Google-Smtp-Source: APXvYqzxBVqKdGBffynWIDBVGnA07GfgS+YlMYz/2MkbpdS6TcJHEfc8t6P88B8fRUxCykiCGiBpuQ== X-Received: by 2002:aca:5f03:: with SMTP id t3mr860249oib.113.1553140794132; Wed, 20 Mar 2019 20:59:54 -0700 (PDT) Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com. [209.85.167.171]) by smtp.gmail.com with ESMTPSA id k23sm1698553otr.6.2019.03.20.20.59.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 20:59:53 -0700 (PDT) Received: by mail-oi1-f171.google.com with SMTP id v7so3648753oie.8 for ; Wed, 20 Mar 2019 20:59:52 -0700 (PDT) X-Received: by 2002:aca:4b03:: with SMTP id y3mr884884oia.21.1553140792562; Wed, 20 Mar 2019 20:59:52 -0700 (PDT) MIME-Version: 1.0 References: <1549348966-14451-1-git-send-email-frederic.chen@mediatek.com> <1549348966-14451-8-git-send-email-frederic.chen@mediatek.com> <1552460044.13953.114.camel@mtksdccf07> In-Reply-To: <1552460044.13953.114.camel@mtksdccf07> From: Tomasz Figa Date: Thu, 21 Mar 2019 12:59:41 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH V0 7/7] [media] platform: mtk-isp: Add Mediatek ISP Pass 1 driver To: Jungo Lin X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_210000_427223_B0FC1739 X-CRM114-Status: GOOD ( 28.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?B?U2VhbiBDaGVuZyAo6YSt5piH5byYKQ==?= , Laurent Pinchart , =?UTF-8?B?UnlubiBXdSAo5ZCz6IKy5oGpKQ==?= , srv_heupstream@mediatek.com, Mauro Carvalho Chehab , =?UTF-8?B?SG9sbWVzIENoaW91ICjpgrHmjLop?= , Jerry-ch Chen , Sj Huang , yuzhao@chromium.org, =?UTF-8?B?Q2hyaXN0aWUgWXUgKOa4uOmbheaDoCk=?= , zwisler@chromium.org, Matthias Brugger , linux-mediatek@lists.infradead.org, Frederic Chen , Hans Verkuil , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , Linux Media Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Mar 13, 2019 at 3:54 PM Jungo Lin wrote: > > On Tue, 2019-03-12 at 19:04 +0900, Tomasz Figa wrote: [snip] > > Instead of opencoding most of this function, one would normally call > > mtk_cam_videoc_try_fmt() first to adjust the format struct and then > > just update the driver state with the adjusted format. > > > > Also, similarly to VIDIOC_TRY_FMT, VIDIOC_SET_FMT doesn't fail unless > > in the very specific cases, as described in > > https://www.kernel.org/doc/html/latest/media/uapi/v4l/vidioc-g-fmt.html#return-value > > . > > > > Ok, below is our revised version of this function. > > int mtk_cam_videoc_s_fmt(struct file *file, void *fh, > struct v4l2_format *f) > { > struct mtk_cam_mem2mem2_device *m2m2 = video_drvdata(file); > struct mtk_cam_dev *cam_dev = mtk_cam_m2m_to_dev(m2m2); > struct mtk_cam_video_device *node = file_to_mtk_cam_node(file); > > /* Get the valid format*/ > mtk_cam_videoc_try_fmt(file, fh, f); > /* Configure to video device */ > mtk_cam_ctx_fmt_set_img(&cam_dev->pdev->dev, > &node->vdev_fmt.fmt.pix_mp, > &f->fmt.pix_mp, > node->queue_id); > > return 0; > } > Looks almost good. We still need to signal the -EBUSY error condition if an attempt to change the format is made while streaming is active. [snip] > > > +static int mtk_cam_videoc_s_meta_fmt(struct file *file, > > > + void *fh, struct v4l2_format *f) > > > +{ > > > + struct mtk_cam_mem2mem2_device *m2m2 = video_drvdata(file); > > > + struct mtk_cam_dev *isp_dev = mtk_cam_m2m_to_dev(m2m2); > > > + struct mtk_cam_ctx *dev_ctx = &isp_dev->ctx; > > > + struct mtk_cam_dev_video_device *node = file_to_mtk_cam_node(file); > > > + int queue_id = mtk_cam_dev_get_queue_id_of_dev_node(isp_dev, node); > > > + > > > > No need for this blank line. > > > > We will fix this coding style in next patch. > > > > + int ret = 0; > > > > Please don't default-initialize without a good reason. > > > > Ok, fix in next patch. > > > > + > > > + if (f->type != node->vbq.type) > > > + return -EINVAL; > > > > Ditto. > > > > Ok, fix in next patch. > > > > + > > > + ret = mtk_cam_ctx_format_load_default_fmt(&dev_ctx->queue[queue_id], f); > > > + > > > > No need for this blank line. > > > > Ok, fix in next patch. > > > > + if (!ret) { > > > + node->vdev_fmt.fmt.meta = f->fmt.meta; > > > + dev_ctx->queue[queue_id].fmt.meta = node->vdev_fmt.fmt.meta; > > > + } else { > > > + dev_warn(&isp_dev->pdev->dev, > > > + "s_meta_fm failed, format not support\n"); > > > > No need for this warning. > > > > Ok, fix in next patch. > > > > + } > > > + > > > + return ret; > > > +} > > > > Actually, why do we even need to do all the things? Do we support > > multiple different meta formats on the same video node? If not, we can > > just have all the TRY_FMT/S_FMT/G_FMT return the hardcoded format. > > > > Ok, it is a good idea. We will return the hardcode format for meta video > devices. > Below is the revision version. > > int mtk_cam_meta_enum_format(struct file *file, > void *fh, struct v4l2_fmtdesc *f) > { > struct mtk_cam_video_device *node = file_to_mtk_cam_node(file); > > f->pixelformat = node->vdev_fmt.fmt.meta.dataformat; > > return 0; > } Need to error out if f->index > 0. Also need to initialize the other output fields - flags and description. [snip] > > > +static u32 mtk_cam_node_get_v4l2_cap(struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + u32 cap = 0; > > > + > > > + if (node_ctx->desc.capture) > > > + if (node_ctx->desc.image) > > > + cap = V4L2_CAP_VIDEO_CAPTURE_MPLANE; > > > + else > > > + cap = V4L2_CAP_META_CAPTURE; > > > + else > > > + if (node_ctx->desc.image) > > > + cap = V4L2_CAP_VIDEO_OUTPUT_MPLANE; > > > + else > > > + cap = V4L2_CAP_META_OUTPUT; > > > + > > > + return cap; > > > +} > > > > Why not just have this defined statically as node_ctx->desc.cap? > > > > Ok, it is refactoring done. > > > > + > > > +static u32 mtk_cam_node_get_format_type(struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + u32 type; > > > + > > > + if (node_ctx->desc.capture) > > > + if (node_ctx->desc.image) > > > + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; > > > + else > > > + type = V4L2_BUF_TYPE_META_CAPTURE; > > > + else > > > + if (node_ctx->desc.image) > > > + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; > > > + else > > > + type = V4L2_BUF_TYPE_META_OUTPUT; > > > + > > > + return type; > > > +} > > > > Why not just have this defined statically as node_ctx->desc.buf_type? > > > > Same as above. > > > > + > > > +static const struct v4l2_ioctl_ops *mtk_cam_node_get_ioctl_ops > > > + (struct mtk_cam_ctx_queue *node_ctx) > > > +{ > > > + const struct v4l2_ioctl_ops *ops = NULL; > > > + > > > + if (node_ctx->desc.image) > > > + ops = &mtk_cam_v4l2_ioctl_ops; > > > + else > > > + ops = &mtk_cam_v4l2_meta_ioctl_ops; > > > + return ops; > > > +} > > > > It's also preferable to just put this inside some structure rather > > than have getter functions. (node_ctx->desc.ioctl_ops?) > > > > Same as above. > Below is the new version for struct mtk_cam_ctx_queue_desc > > /* > * struct mtk_cam_ctx_queue_desc - queue attributes > * setup by device context owner > * @id: id of the context queue > * @name: media entity name > * @cap: mapped to V4L2 capabilities > * @buf_type: mapped to V4L2 buffer type > * @capture: true for capture queue (device to user) > * false for output queue (from user to device) > * @image: true for image, false for meta data > * @smem_alloc: Using the cam_smem_drv as alloc ctx or not > * @dma_port: the dma port associated to the buffer > * @fmts: supported format > * @num_fmts: the number of supported formats > * @default_fmt_idx: default format of this queue > * @max_buf_count: maximum V4L2 buffer count > * @max_buf_count: mapped to v4l2_ioctl_ops > */ > struct mtk_cam_ctx_queue_desc { > u8 id; > char *name; > u32 cap; > u32 buf_type; > u32 dma_port; > u32 smem_alloc:1; > u8 capture:1; > u8 image:1; > u8 num_fmts; > u8 default_fmt_idx; > u8 max_buf_count; > const struct v4l2_ioctl_ops *ioctl_ops; > struct v4l2_format *fmts; > }; SGTM +/- the missing kerneldoc for the new fields. [snip] > > Sorry, ran out of time for today. Fourth part will come. :) > > > > Best regards, > > Tomasz > > > > Appreciate your support and hard working on this review. > We will look forward your part 4 review. Thanks for replying to all the comments, it's very helpful. As I mentioned in another reply, I'm going to be busy for the next few days, so I'd suggest addressing the existing comments, fixing any v4l2-compliance issues and also checking if any changes could be applied to the other drivers (DIP, FD, Seninf, MDP) too and then sending RFC V1. Best regards, Tomasz _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel