From patchwork Mon Sep 12 07:47:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Songjun Wu X-Patchwork-Id: 9325859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 448F66048B for ; Mon, 12 Sep 2016 07:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3692C28BD0 for ; Mon, 12 Sep 2016 07:49:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26D2428BD4; Mon, 12 Sep 2016 07:49:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD7A28BD0 for ; Mon, 12 Sep 2016 07:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932640AbcILHsy (ORCPT ); Mon, 12 Sep 2016 03:48:54 -0400 Received: from exsmtp01.microchip.com ([198.175.253.37]:26258 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755094AbcILHsv (ORCPT ); Mon, 12 Sep 2016 03:48:51 -0400 Received: from shaarm01.corp.atmel.com (10.10.76.4) by CHN-SV-EXCH01.mchp-main.com (10.10.76.37) with Microsoft SMTP Server id 14.3.181.6; Mon, 12 Sep 2016 00:48:49 -0700 From: Songjun Wu To: , Hans Verkuil CC: Songjun Wu , Mauro Carvalho Chehab , , Subject: [PATCH] [media] atmel-isc: set the format on the first open Date: Mon, 12 Sep 2016 15:47:24 +0800 Message-ID: <1473666444-20271-1-git-send-email-songjun.wu@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Set the current format on the first open. Signed-off-by: Songjun Wu --- drivers/media/platform/atmel/atmel-isc.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index db6773d..ed8050d 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -924,10 +924,16 @@ static int isc_open(struct file *file) goto unlock; ret = v4l2_subdev_call(sd, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD) + if (ret < 0 && ret != -ENOIOCTLCMD) { v4l2_fh_release(file); - else - ret = 0; + goto unlock; + } + + ret = isc_set_fmt(isc, &isc->fmt); + if (ret) { + v4l2_subdev_call(sd, core, s_power, 0); + v4l2_fh_release(file); + } unlock: mutex_unlock(&isc->lock); @@ -1118,8 +1124,16 @@ static int isc_set_default_fmt(struct isc_device *isc) .pixelformat = isc->user_formats[0]->fourcc, }, }; + int ret; - return isc_set_fmt(isc, &f); + ret = isc_try_fmt(isc, &f, NULL); + if (ret) + return ret; + + isc->current_fmt = isc->user_formats[0]; + isc->fmt = f; + + return 0; } static int isc_async_complete(struct v4l2_async_notifier *notifier) @@ -1172,20 +1186,12 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) return ret; } - ret = v4l2_subdev_call(sd_entity->sd, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD) - return ret; - ret = isc_set_default_fmt(isc); if (ret) { v4l2_err(&isc->v4l2_dev, "Could not set default format\n"); return ret; } - ret = v4l2_subdev_call(sd_entity->sd, core, s_power, 0); - if (ret < 0 && ret != -ENOIOCTLCMD) - return ret; - /* Register video device */ strlcpy(vdev->name, ATMEL_ISC_NAME, sizeof(vdev->name)); vdev->release = video_device_release_empty;