Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp593002imu; Fri, 9 Nov 2018 02:55:56 -0800 (PST) X-Google-Smtp-Source: AJdET5fK2eXaZor+QS0Eh8CDrvoZa381TdvGDUtwJd0ha2vZ7paiyEHlxx3EhdsFKAMQ/66Hv9sm X-Received: by 2002:a63:5907:: with SMTP id n7mr6933174pgb.435.1541760956489; Fri, 09 Nov 2018 02:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541760956; cv=none; d=google.com; s=arc-20160816; b=e7vC1bAUGoPIB9aJNPKcT7qT5bszluSMuK+rL8lulCiutX8z3ILsUYZKOKbCWjpL7E xxRxbKX9jH67ioVKZ7Lll+lwS0YIrtnSujdMFypJ/pWDrEi6sDoJ8thsI0Y//SE/23Mr FS8cWbyhQU5NFPK3u+pe5qLb5xfBSfGb19/+EomQUkyC410jeFZVu1cc+OaQcXhYLixV zwL2kgcfEYXgXvSKEGBMASMHCJHrmY/AR3BjnaZjSRGFGMnYxM+FK318+ZyywiqHppy1 +SoXAz7bSRAtrb4f723kt28/iirH/8TxqCQJN3jpKDLVSntBSfoOSYX+vLbvAIOU2r22 Bdqg== 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; bh=BwYg7mDoRR5Ty0JXaax1V4+asaUBTfH0kPEUPESJ7Xg=; b=BEG4ZShvBptsem1SE4cTM6EOqRfc0+Z5il1mBh75jFo8N7yImiq2OlRzOoC6g2QnuM SvvOanC8EwqyURZ9//PXlzwj+TZtmIr724L/9Efj0cHvuLi7PT0jofTx3Fdk3b5IPqtb rmodcimfl5mwAOZlb8KPVtTAQX+VvsQ10yynMjjWnaPQT44YrocJ95MlO2e5QNlbRP6F 68KDh/WL7QXfqoh1rKemqoust9N8zeMM+oNcvZAXHb6s88CPnrMqK9AL0A3awnNQgJHB ozwRfQAmagnTcV3PGVbq/28K6AJJdVG1TgQTBq/MkM+yAuMePOBLO3E1kXKJGgch19NR ERYA== ARC-Authentication-Results: i=1; mx.google.com; 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 m33si5859873pgl.379.2018.11.09.02.55.39; Fri, 09 Nov 2018 02:55:56 -0800 (PST) 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; 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 S1728204AbeKIUfI (ORCPT + 99 others); Fri, 9 Nov 2018 15:35:08 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:47348 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbeKIUfH (ORCPT ); Fri, 9 Nov 2018 15:35:07 -0500 Received: from [IPv6:2001:420:44c1:2579:64ae:ee5d:da4d:25e4] ([IPv6:2001:420:44c1:2579:64ae:ee5d:da4d:25e4]) by smtp-cloud7.xs4all.net with ESMTPA id L4RCgWGxdw2L8L4RFgna6C; Fri, 09 Nov 2018 11:55:00 +0100 Subject: Re: [PATCH v4 2/2] media: platform: Add Aspeed Video Engine driver To: Eddie James , Eddie James , linux-kernel@vger.kernel.org Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-aspeed@lists.ozlabs.org, andrew@aj.id.au, openbmc@lists.ozlabs.org, robh+dt@kernel.org, mchehab@kernel.org, linux-media@vger.kernel.org References: <1538769466-14860-1-git-send-email-eajames@linux.ibm.com> <1538769466-14860-3-git-send-email-eajames@linux.ibm.com> <7027cd38-b8f5-08b2-0536-eed1c6a0516b@linux.vnet.ibm.com> From: Hans Verkuil Message-ID: Date: Fri, 9 Nov 2018 11:54:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <7027cd38-b8f5-08b2-0536-eed1c6a0516b@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfP+liCimk7WmKQfcqMizLyqI3mCQYabsSVDJM3DWgsUvcD4xwkxPSlY0jPpFmA2CAjJ995QIwvgMQWNsLXXGyWulSSha7QbKQvrgRof3fVkLprSK2b42 WJvkmH/SZFyVp4DpLCbubUz/qNUmbnWq3prwBk4ng+Q0NuFVCMD2oP16gvLAlQgrPWCf8X3axbztvUkRMUFtOXJVmASF+yoUpM5TtAxT+xMYMk7WqNk+glt+ c3JWC1Sh9u3qi0JnfF1f7gzOw5FUVQm17SK+E/q/X73/YMsGfbw0DuiSLYHJCwQ3TiexltdM2PYCRfEcuQl4eLgOWK+qbwNA6DJ39jSgSfaDpW6+Qj5HwVva ziz3nLa2trQc6u8f2w3HS5XTxKOzx+gAl2KJHSOLdscvmEWdqtarjw3uMa52bgYuauOWLst9ikBdnt3odOHq90hc28wGIfFudVL0BVYwYK+GJY9iGMbbpb76 7KSuVWgKv212+lFksppqgFFYT8IKLKL943EZt17R/wsBdRipx3QBw2M5NTr5BnndnB722b9IJ/2zNyPCRMCzJFeSIDLmXqGPTA3woG/kJnrYLFAR4kRIizIC 3WyDDvuSkSYgvV5I29aynPP2nTidhF1B9FRrw+MAAZk/UmfOroefnQtrFmKrhhQSFHk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eddie, Sorry for the delay, I've been away for the past two weeks and I've been catching up ever since I came back. On 11/08/18 16:48, Eddie James wrote: > > > On 10/19/2018 03:26 PM, Eddie James wrote: >> >> >> On 10/12/2018 07:22 AM, Hans Verkuil wrote: >>> On 10/05/2018 09:57 PM, Eddie James wrote: >>>> The Video Engine (VE) embedded in the Aspeed AST2400 and AST2500 SOCs >>>> can capture and compress video data from digital or analog sources. >>>> With >>>> the Aspeed chip acting a service processor, the Video Engine can >>>> capture >>>> the host processor graphics output. >>>> >>>> Add a V4L2 driver to capture video data and compress it to JPEG images. >>>> Make the video frames available through the V4L2 streaming interface. >>>> >>>> Signed-off-by: Eddie James >>>> --- >>>> MAINTAINERS | 8 + >>>> drivers/media/platform/Kconfig | 8 + >>>> drivers/media/platform/Makefile | 1 + >>>> drivers/media/platform/aspeed-video.c | 1674 >>>> +++++++++++++++++++++++++++++++++ >>>> 4 files changed, 1691 insertions(+) >>>> create mode 100644 drivers/media/platform/aspeed-video.c >>>> >>> >>> >>>> +static int aspeed_video_enum_input(struct file *file, void *fh, >>>> + struct v4l2_input *inp) >>>> +{ >>>> + if (inp->index) >>>> + return -EINVAL; >>>> + >>>> + strscpy(inp->name, "Host VGA capture", sizeof(inp->name)); >>>> + inp->type = V4L2_INPUT_TYPE_CAMERA; >>>> + inp->capabilities = V4L2_IN_CAP_DV_TIMINGS; >>>> + inp->status = V4L2_IN_ST_NO_SIGNAL | V4L2_IN_ST_NO_SYNC; >>> This can't be right. If there is a valid signal, then status should >>> be 0. >>> And ideally you can tell the difference between no signal and no sync >>> as well. >>> >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_get_input(struct file *file, void *fh, >>>> unsigned int *i) >>>> +{ >>>> + *i = 0; >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_set_input(struct file *file, void *fh, >>>> unsigned int i) >>>> +{ >>>> + if (i) >>>> + return -EINVAL; >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_get_parm(struct file *file, void *fh, >>>> + struct v4l2_streamparm *a) >>>> +{ >>>> + struct aspeed_video *video = video_drvdata(file); >>>> + >>>> + a->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; >>>> + a->parm.capture.readbuffers = 3; >>>> + a->parm.capture.timeperframe.numerator = 1; >>>> + if (!video->frame_rate) >>>> + a->parm.capture.timeperframe.denominator = MAX_FRAME_RATE + 1; >>>> + else >>>> + a->parm.capture.timeperframe.denominator = video->frame_rate; >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_set_parm(struct file *file, void *fh, >>>> + struct v4l2_streamparm *a) >>>> +{ >>>> + unsigned int frame_rate = 0; >>>> + struct aspeed_video *video = video_drvdata(file); >>>> + >>>> + a->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; >>>> + a->parm.capture.readbuffers = 3; >>>> + >>>> + if (a->parm.capture.timeperframe.numerator) >>>> + frame_rate = a->parm.capture.timeperframe.denominator / >>>> + a->parm.capture.timeperframe.numerator; >>>> + >>>> + if (!frame_rate || frame_rate > MAX_FRAME_RATE) { >>>> + frame_rate = 0; >>>> + >>>> + /* >>>> + * Set to max + 1 to differentiate between max and 0, which >>>> + * means "don't care". >>> But what does "don't care" mean in practice? It's still not clear to >>> me how this >>> is supposed to work. >>> >>>> + */ >>>> + a->parm.capture.timeperframe.denominator = MAX_FRAME_RATE + 1; >>> And regardless of anything else this timeperframe is out of the range >>> that >>> aspeed_video_enum_frameintervals() returns. >>> >>>> + a->parm.capture.timeperframe.numerator = 1; >>>> + } >>>> + >>>> + if (video->frame_rate != frame_rate) { >>>> + video->frame_rate = frame_rate; >>>> + aspeed_video_update(video, VE_CTRL, VE_CTRL_FRC, >>>> + FIELD_PREP(VE_CTRL_FRC, frame_rate)); >>>> + } >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_enum_framesizes(struct file *file, void *fh, >>>> + struct v4l2_frmsizeenum *fsize) >>>> +{ >>>> + struct aspeed_video *video = video_drvdata(file); >>>> + >>>> + if (fsize->index) >>>> + return -EINVAL; >>>> + >>>> + if (fsize->pixel_format != V4L2_PIX_FMT_JPEG) >>>> + return -EINVAL; >>>> + >>>> + fsize->discrete.width = video->pix_fmt.width; >>>> + fsize->discrete.height = video->pix_fmt.height; >>>> + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_enum_frameintervals(struct file *file, void >>>> *fh, >>>> + struct v4l2_frmivalenum *fival) >>>> +{ >>>> + struct aspeed_video *video = video_drvdata(file); >>>> + >>>> + if (fival->index) >>>> + return -EINVAL; >>>> + >>>> + if (fival->width != video->width || fival->height != >>>> video->height) >>>> + return -EINVAL; >>>> + >>>> + if (fival->pixel_format != V4L2_PIX_FMT_JPEG) >>>> + return -EINVAL; >>>> + >>>> + fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS; >>>> + >>>> + fival->stepwise.min.denominator = MAX_FRAME_RATE; >>>> + fival->stepwise.min.numerator = 1; >>>> + fival->stepwise.max.denominator = 1; >>>> + fival->stepwise.max.numerator = 1; >>>> + fival->stepwise.step = fival->stepwise.max; >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int aspeed_video_set_dv_timings(struct file *file, void *fh, >>>> + struct v4l2_dv_timings *timings) >>>> +{ >>>> + struct aspeed_video *video = video_drvdata(file); >>>> + >>> If vb2_is_busy() returns true, then return -EBUSY here. It is not >>> allowed to >>> set the timings while vb2 is busy. >> >> Buffer ioctls (Input 0): >> fail: v4l2-test-buffers.cpp(344): node->s_dv_timings(timings) >> fail: v4l2-test-buffers.cpp(452): testCanSetSameTimings(node) >> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL >> >> Streaming ioctls: >> test read/write: OK >> test blocking wait: OK >> fail: v4l2-test-buffers.cpp(344): node->s_dv_timings(timings) >> fail: v4l2-test-buffers.cpp(637): testCanSetSameTimings(node) >> fail: v4l2-test-buffers.cpp(952): captureBufs(node, q, m2m_q, >> frame_count, false) >> test MMAP: FAIL >> >> Built from v4l-utils c36dbbdfa8b30b2badd4f893b59d0bd4f0bd12aa >> >> Adding this causes some of the v4l2-compliance streaming tests to >> fail, and prevents my own application from being able to call >> S_DV_TIMINGS after detecting a resolution change, despite calling >> streamoff and unmapping all the buffers first. > > Any thoughts on this Hans? The compliance fail is because there is a requirement that if you set new timings that are equal to the existing timings, then that should work (and is effectively a NOP operation). So in the code you can do something similar to what vivid does: if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap, 0, false)) return 0; if (vb2_is_busy(&dev->vb_vid_cap_q)) return -EBUSY; You can probably get away with just checking width, height and interlaced in this driver, rather than calling v4l2_match_dv_timings. If the resolution changes, however, then you need to completely free all buffers (i.e. close the fd or call VIDIOC_REQBUFS with count = 0) before you can set new timings. So streamoff + unmap is not enough. Streamoff only returns the buffers to userspace, it doesn't free them. Regards, Hans