From patchwork Thu Nov 11 17:27:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12615515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADA45C433EF for ; Thu, 11 Nov 2021 17:28:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9105161884 for ; Thu, 11 Nov 2021 17:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234355AbhKKRaw (ORCPT ); Thu, 11 Nov 2021 12:30:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:47820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbhKKRaw (ORCPT ); Thu, 11 Nov 2021 12:30:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D86BE61284; Thu, 11 Nov 2021 17:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636651682; bh=Ue73mybcp2/mEsojqL7x52d9zudKOWx0mXr346D60Nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZfWdtpjH4ajAqqrxuFYzxisShfAsFQx4Ix4Of+XanMiPf0QsZ/xPqf1j998WNMHfM ojb92CsTLB7EWmBZ8bRtbmlvuoMtnFGCcjuUjsSv5mzeWqJKXGcbh3bOPEbe1mfM4P s6WyRx+iY1U1wJcuxgnirpo3f9v+kyqfIc4EvdyW1p0FOfCpsmKRMdWkK9asgzRvVK pcy1paW6GNMO21h4WzMLrQu5h/hUBfs3tfS/INUGpkfAFv/18D41jbJEEqhdIhGr4f HIatdo0IfGkV3ZsuG40Yh1VbjyxDxgqP3MEichFYuM4l17b9RM58KIgcBBPLt6UkqP F/MOHROCacX5w== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mlDrj-0001oc-W0; Thu, 11 Nov 2021 17:27:59 +0000 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Deepak R Varma , Greg Kroah-Hartman , Hans Verkuil , Hans de Goede , Mauro Carvalho Chehab , Sakari Ailus , Tomi Valkeinen , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 1/3] media: atomisp-ov2680: implement enum frame intervals Date: Thu, 11 Nov 2021 17:27:56 +0000 Message-Id: X-Mailer: git-send-email 2.33.1 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Allow the sensor to report the per-resolution frame interval. It should be noticed that, despite the ov2680 datasheet says that, for resolutions <= 1280x720, the sensor supports 60fps, the data at ov2680.h tells otherwise, limiting it to 30fps. Not sure yet if this is a limitation of atomisp or if it is just because the tables are incorrect. Signed-off-by: Mauro Carvalho Chehab --- See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1636651027.git.mchehab+huawei@kernel.org/ .../media/atomisp/i2c/atomisp-ov2680.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index d24f8830fd94..428e98310b3c 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -1075,6 +1075,26 @@ static int ov2680_enum_frame_size(struct v4l2_subdev *sd, return 0; } +static int ov2680_enum_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_interval_enum *fie) +{ + struct v4l2_fract fract; + + if (fie->index >= N_RES_PREVIEW || + fie->width > ov2680_res_preview[0].width || + fie->height > ov2680_res_preview[0].height || + fie->which > V4L2_SUBDEV_FORMAT_ACTIVE) + return -EINVAL; + + fract.denominator =ov2680_res_preview[fie->index].fps; + fract.numerator = 1; + + fie->interval = fract; + + return 0; +} + static int ov2680_g_skip_frames(struct v4l2_subdev *sd, u32 *frames) { struct ov2680_device *dev = to_ov2680_sensor(sd); @@ -1103,6 +1123,7 @@ static const struct v4l2_subdev_core_ops ov2680_core_ops = { static const struct v4l2_subdev_pad_ops ov2680_pad_ops = { .enum_mbus_code = ov2680_enum_mbus_code, .enum_frame_size = ov2680_enum_frame_size, + .enum_frame_interval = ov2680_enum_frame_interval, .get_fmt = ov2680_get_fmt, .set_fmt = ov2680_set_fmt, }; From patchwork Thu Nov 11 17:27:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12615517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F374AC433F5 for ; Thu, 11 Nov 2021 17:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D117161502 for ; Thu, 11 Nov 2021 17:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234374AbhKKRay (ORCPT ); Thu, 11 Nov 2021 12:30:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:47818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234321AbhKKRaw (ORCPT ); Thu, 11 Nov 2021 12:30:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D5C38610A2; Thu, 11 Nov 2021 17:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636651682; bh=fVWeNM/EkROzLgkEOagtV1bVZ4cBFHPDPoXfH7hX2iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b04t9yWlvJRuOR91Dqy359Zxx3vihLWJzeIBHsSbeg+Q39SAljOBx/QChJXlpPB0i mOaKnn/3dTdDHtrleoX6tiSsi6FCuRq0NSR+s0SRSAG8JTlTehqyYfrfpbydYbzhJm NGS5Yi7MrO+9eaNKrti9ah36DOsgu/+EZuN0TEd2YtaXzoj52ZAWFf9D5aYCc83vfc PUeNoQP7+leSt37f9GQrMBWR+Bp6tNV+iRbENPMuufvFhERqmbXCFNxQnmA/uPV92a CCRPylP0ehjme0bt1CAemgW943hA6pgRRr3s5t1KYFm3H1F/64hR6KmZvlDOcwR6FK 011h452aw0QDw== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mlDrk-0001of-0C; Thu, 11 Nov 2021 17:28:00 +0000 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Bhaskar Chowdhury , Deepak R Varma , Greg Kroah-Hartman , Hans Verkuil , Hans de Goede , Mauro Carvalho Chehab , Randy Dunlap , Sakari Ailus , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 2/3] media: atomisp-ov2680: adjust the maximum frame rate Date: Thu, 11 Nov 2021 17:27:57 +0000 Message-Id: X-Mailer: git-send-email 2.33.1 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov2680 supports a maximum bandwidth of 660Mbps and allows up to 60fps when the resolution is below 720p. Adjust the sensor's table to reflect that. Signed-off-by: Mauro Carvalho Chehab --- See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1636651027.git.mchehab+huawei@kernel.org/ drivers/staging/media/atomisp/i2c/ov2680.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index cb3c37d1c38e..4e351196fe34 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -822,7 +822,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 1280, .height = 720, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, @@ -835,7 +835,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 800, .height = 600, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, @@ -848,7 +848,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 720, .height = 592, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, @@ -861,7 +861,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 656, .height = 496, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, @@ -874,7 +874,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 336, .height = 256, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, @@ -887,7 +887,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 352, .height = 288, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, @@ -900,7 +900,7 @@ static struct ov2680_resolution ov2680_res_preview[] = { { .width = 176, .height = 144, - .fps = 30, + .fps = 60, .pix_clk_freq = 66, .pixels_per_line = 1698,//1704, .lines_per_frame = 1294, From patchwork Thu Nov 11 17:27:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12615521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F5DFC433EF for ; Thu, 11 Nov 2021 17:28:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED4C461884 for ; Thu, 11 Nov 2021 17:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234365AbhKKRax (ORCPT ); Thu, 11 Nov 2021 12:30:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:47830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234310AbhKKRaw (ORCPT ); Thu, 11 Nov 2021 12:30:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DAD3061354; Thu, 11 Nov 2021 17:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636651682; bh=cEvARZE01PkG5TfS7VOFuTCa6kXXGHQhZOv8rZLZKX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g10FQFg6bijmqsogYzY7FXhYnWUwzrFsdM2nEFUdsho+tV2WGb7Qce/HiFKH/0r1c BZNFbREEgrBHY8mYXwRVbkO8UAqqRj9CJ8Ux4Lc2csbh3589tU1CBxqvjEirW4aIME FJtMAJyhan8McNLyOdMY3FNBTvETavyQl6xIQStfj0mcXE6wvKjBy7w6TPpKA7kwfe r9mTcU7b4dyRgVMIe2aVMCMfUDQ035pNC9k5FJlXz1VMrx7X+ArSPsuHEDIDlFltTI CmMPg4/vYjQXlHgvAq4wJUsGa5fcPbDFlcJkRdI6yQmCeEjfSOFFbnEM912Hsi2ZCO 9nrpXlYYABp0g== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mlDrk-0001oi-0f; Thu, 11 Nov 2021 17:28:00 +0000 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Dan Carpenter , Greg Kroah-Hartman , Ingo Molnar , Kaixu Xia , Mauro Carvalho Chehab , Peter Zijlstra , Sakari Ailus , Tsuchiya Yuto , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 3/3] media: atomisp: implement enum framesize/frameinterval Date: Thu, 11 Nov 2021 17:27:58 +0000 Message-Id: <88cb16535787c259a088e5bab47146fd1730dd6e.1636651027.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add logic to enumerate sensor's frame size and interval. Signed-off-by: Mauro Carvalho Chehab --- See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1636651027.git.mchehab+huawei@kernel.org/ .../staging/media/atomisp/pci/atomisp_ioctl.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 2fb64d5cbead..b2d3b8349234 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -766,6 +766,57 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) return ret; } +static int atomisp_enum_framesizes(struct file *file, void *priv, + struct v4l2_frmsizeenum *fsize) +{ + struct video_device *vdev = video_devdata(file); + struct atomisp_device *isp = video_get_drvdata(vdev); + struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; + struct v4l2_subdev_frame_size_enum fse = { + .index = fsize->index, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; + int ret; + + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, + pad, enum_frame_size, NULL, &fse); + if (ret) + return ret; + + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; + fsize->discrete.width = fse.max_width - pad_w; + fsize->discrete.height = fse.max_height - pad_h; + + return 0; +} + +static int atomisp_enum_frameintervals(struct file *file, void *priv, + struct v4l2_frmivalenum *fival) +{ + struct video_device *vdev = video_devdata(file); + struct atomisp_device *isp = video_get_drvdata(vdev); + struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; + struct v4l2_subdev_frame_interval_enum fie = { + .code = atomisp_in_fmt_conv[0].code, + .index = fival->index, + .width = fival->width, + .height = fival->height, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; + int ret; + + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, + pad, enum_frame_interval, NULL, + &fie); + if (ret) + return ret; + + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; + fival->discrete = fie.interval; + + return ret; +} + static int atomisp_enum_fmt_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { @@ -3214,6 +3265,8 @@ const struct v4l2_ioctl_ops atomisp_ioctl_ops = { .vidioc_g_ctrl = atomisp_g_ctrl, .vidioc_s_ext_ctrls = atomisp_s_ext_ctrls, .vidioc_g_ext_ctrls = atomisp_g_ext_ctrls, + .vidioc_enum_framesizes = atomisp_enum_framesizes, + .vidioc_enum_frameintervals = atomisp_enum_frameintervals, .vidioc_enum_fmt_vid_cap = atomisp_enum_fmt_cap, .vidioc_try_fmt_vid_cap = atomisp_try_fmt_cap, .vidioc_g_fmt_vid_cap = atomisp_g_fmt_cap,