From patchwork Mon Jun 19 14:48:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 105850 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp918205qgd; Mon, 19 Jun 2017 08:03:01 -0700 (PDT) X-Received: by 10.98.138.16 with SMTP id y16mr26039267pfd.131.1497884581132; Mon, 19 Jun 2017 08:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497884581; cv=none; d=google.com; s=arc-20160816; b=trZoYvhNIEf6uL9xZwVpUZndKppPfFLql1t1A8EboXXh9I+aniAmFak3J5kuuPO+Qu zaXAC2n9NZqC5zYh+rjZxqdCQqObqcSXeNXnZsJ9lSNjWujxHykxCHIzSzoByXAT+InW CVAIq1PAj5rhWD+yFwNzgycjhBOQckI22MPAK6Pd7bCqI0PI2ho8dUr8YDeJHawxdvcC dwBdochDGvq1Jp5S1+tkJhrkUG7iXMpX1SRq5fcUoMaiFurFm/O783akT5jb3uqWK7Eo l/mpnEsYn+3vuZ/zkgEh2MKKQvqgtxRNQ3UlLcueBgbdtxt7nHunc2zLu499Ckhnc3kP Layw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2ghFsRonEKlLbgsEhVxhpGLkEqHRuMnpPXgACBKdYTg=; b=xF8oe1GKoAEMn7CLZ5srv5XOWhQ5rYe1cfnyE4vJCzfrkMaS/KyKx3DRYyxbk8US0F UD9fDqcg/IbnzHRsP9rJXxFEQGc7XRMza6h/0c8NOMeZq31iO+ybY/fcnEd6z/n+4zF/ sSlDuQRdw8OFXorbaZeGKQLszITuq4Dnfl5injJdi1Jayg5ZmcXMwhh6gPiP9JbNGJnw 6t8/rFE3Rl1P4fXhXXJsncXLAaQu8CLzzrA/BZOz4OkBUa4H3QXAxx0Ana1nYJC51YKZ VAVhXqd6QSUbgRixNnZsk+QM06f1BedCnA3R00prDCD3ooAZbnGDwu4ABGwGSTMXapFI mmbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33si8983193pld.477.2017.06.19.08.03.00; Mon, 19 Jun 2017 08:03:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751771AbdFSPCz (ORCPT + 4 others); Mon, 19 Jun 2017 11:02:55 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:56055 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752167AbdFSO4r (ORCPT ); Mon, 19 Jun 2017 10:56:47 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 11E32CBB0; Mon, 19 Jun 2017 17:49:23 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, hans.verkuil@cisco.com, javier@osg.samsung.com, s.nawrocki@samsung.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Todor Tomov Subject: [PATCH v2 02/19] MAINTAINERS: Add Qualcomm Camera subsystem driver Date: Mon, 19 Jun 2017 17:48:22 +0300 Message-Id: <1497883719-12410-3-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497883719-12410-1-git-send-email-todor.tomov@linaro.org> References: <1497883719-12410-1-git-send-email-todor.tomov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add an entry for Qualcomm Camera subsystem driver. Signed-off-by: Todor Tomov --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) -- 1.9.1 diff --git a/MAINTAINERS b/MAINTAINERS index 09b5ab6..524fe09 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10570,6 +10570,14 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git S: Supported F: drivers/net/wireless/ath/ath10k/ +QUALCOMM CAMERA SUBSYSTEM DRIVER +M: Todor Tomov +L: linux-media@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/media/qcom,camss.txt +F: Documentation/media/v4l-drivers/qcom_camss.rst +F: drivers/media/platform/qcom/camss/ + QUALCOMM EMAC GIGABIT ETHERNET DRIVER M: Timur Tabi L: netdev@vger.kernel.org From patchwork Mon Jun 19 14:48:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 105851 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp918208qgd; Mon, 19 Jun 2017 08:03:01 -0700 (PDT) X-Received: by 10.98.211.89 with SMTP id q86mr26029636pfg.126.1497884581350; Mon, 19 Jun 2017 08:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497884581; cv=none; d=google.com; s=arc-20160816; b=Q8DVh4pczhki7jCbSebclWseSA3eATNEoJ0RPGQ+4E761pjMjegj2idFeLPMQOyXIX jA4M931v0uMrTxyy3o3KvnV8pJWIFepKvlgXb4m3/j9pIhN7GjvspW4G2ynOVgLZTd02 Miaxt0SiOYuGwvCmRv2aO3hhurDfxnbpa2qvcaCqb6GXKCLThuJRvLvhDxW9C85hDXnH i5gjwftUQX3CTH27vVffQZVL+wjQx3lw+ateQo9I/T8cvmpIX3jtelDzYgBkUhYDZ/nd fDT0NDR7DZm/k865LjFHlojNK7SHgV92Y9BS4TWQZvJZ00TWW78eeJRol0AKv3asnl8h J1nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ITq9AE05CkMAyswaxfWPTl/Savp/yu4hqpew1HjCgbs=; b=Z0Al99Qed3fO/dZnQSs+24vZfGUeOginMJ+BqcO1xpoVjZ/SebpgL/0D0RH6x/zExO wVD3EMN8bUltjqpJ0WLov/qKcFAZrgcol8xSI419gIxCaipGIi2jrQtN2lBa9uPYVxIo YU16x3stIj4G+EYNsjlG9qzwvugC+40v9m+dUVQNpYy+WRNMuLCh+tyz6be+riYrsDec 5UDqm7ZrjA6fcFcidqHznd/NxLBqr2EiwamwAXkaW0Lm71+2kiKFf/+h1ajgl/CcRJlN nid+r4gQU22rTqVFuzsMnC9nNFptqlq7HVWG+//WE4UjL49Z2w6z/l24W3vQhBPFNnpS bz6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33si8983193pld.477.2017.06.19.08.03.01; Mon, 19 Jun 2017 08:03:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752356AbdFSPC4 (ORCPT + 4 others); Mon, 19 Jun 2017 11:02:56 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:56039 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752159AbdFSO4q (ORCPT ); Mon, 19 Jun 2017 10:56:46 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 1F5F64F890; Mon, 19 Jun 2017 17:49:24 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, hans.verkuil@cisco.com, javier@osg.samsung.com, s.nawrocki@samsung.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Todor Tomov Subject: [PATCH v2 16/19] camss: vfe: Add interface for cropping Date: Mon, 19 Jun 2017 17:48:36 +0300 Message-Id: <1497883719-12410-17-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497883719-12410-1-git-send-email-todor.tomov@linaro.org> References: <1497883719-12410-1-git-send-email-todor.tomov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Extend selection ioctls to handle cropping configuration. Signed-off-by: Todor Tomov --- drivers/media/platform/qcom/camss-8x16/vfe.c | 191 +++++++++++++++++++++------ drivers/media/platform/qcom/camss-8x16/vfe.h | 1 + 2 files changed, 150 insertions(+), 42 deletions(-) -- 1.9.1 diff --git a/drivers/media/platform/qcom/camss-8x16/vfe.c b/drivers/media/platform/qcom/camss-8x16/vfe.c index a64f158..b97aefa 100644 --- a/drivers/media/platform/qcom/camss-8x16/vfe.c +++ b/drivers/media/platform/qcom/camss-8x16/vfe.c @@ -1960,6 +1960,26 @@ static int vfe_set_stream(struct v4l2_subdev *sd, int enable) } /* + * __vfe_get_crop - Get pointer to crop selection structure + * @line: VFE line + * @cfg: V4L2 subdev pad configuration + * @which: TRY or ACTIVE format + * + * Return pointer to TRY or ACTIVE crop rectangle structure + */ +static struct v4l2_rect * +__vfe_get_crop(struct vfe_line *line, + struct v4l2_subdev_pad_config *cfg, + enum v4l2_subdev_format_whence which) +{ + if (which == V4L2_SUBDEV_FORMAT_TRY) + return v4l2_subdev_get_try_crop(&line->subdev, cfg, + MSM_VFE_PAD_SRC); + + return &line->crop; +} + +/* * vfe_try_format - Handle try format by pad subdev method * @line: VFE line * @cfg: V4L2 subdev pad configuration @@ -2007,7 +2027,7 @@ static void vfe_try_format(struct vfe_line *line, if (line->id == VFE_LINE_PIX) { struct v4l2_rect *rect; - rect = __vfe_get_compose(line, cfg, which); + rect = __vfe_get_crop(line, cfg, which); fmt->width = rect->width; fmt->height = rect->height; @@ -2092,6 +2112,49 @@ static void vfe_try_compose(struct vfe_line *line, } /* + * vfe_try_crop - Handle try crop selection by pad subdev method + * @line: VFE line + * @cfg: V4L2 subdev pad configuration + * @rect: pointer to v4l2 rect structure + * @which: wanted subdev format + */ +static void vfe_try_crop(struct vfe_line *line, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_rect *rect, + enum v4l2_subdev_format_whence which) +{ + struct v4l2_rect *compose; + + compose = __vfe_get_compose(line, cfg, which); + + if (rect->width > compose->width) + rect->width = compose->width; + + if (rect->width + rect->left > compose->width) + rect->left = compose->width - rect->width; + + if (rect->height > compose->height) + rect->height = compose->height; + + if (rect->height + rect->top > compose->height) + rect->top = compose->height - rect->height; + + /* wm in line based mode writes multiple of 16 horizontally */ + rect->left += (rect->width & 0xf) >> 1; + rect->width &= ~0xf; + + if (rect->width < 16) { + rect->left = 0; + rect->width = 16; + } + + if (rect->height < 4) { + rect->top = 0; + rect->height = 4; + } +} + +/* * vfe_enum_mbus_code - Handle pixel format enumeration * @sd: VFE V4L2 subdevice * @cfg: V4L2 subdev pad configuration @@ -2255,34 +2318,58 @@ static int vfe_get_selection(struct v4l2_subdev *sd, { struct vfe_line *line = v4l2_get_subdevdata(sd); struct v4l2_subdev_format fmt = { 0 }; - struct v4l2_rect *compose; + struct v4l2_rect *rect; int ret; - if (line->id != VFE_LINE_PIX || sel->pad != MSM_VFE_PAD_SINK) + if (line->id != VFE_LINE_PIX) return -EINVAL; - switch (sel->target) { - case V4L2_SEL_TGT_COMPOSE_BOUNDS: - fmt.pad = sel->pad; - fmt.which = sel->which; - ret = vfe_get_format(sd, cfg, &fmt); - if (ret < 0) - return ret; - sel->r.left = 0; - sel->r.top = 0; - sel->r.width = fmt.format.width; - sel->r.height = fmt.format.height; - break; - case V4L2_SEL_TGT_COMPOSE: - compose = __vfe_get_compose(line, cfg, sel->which); - if (compose == NULL) + if (sel->pad == MSM_VFE_PAD_SINK) + switch (sel->target) { + case V4L2_SEL_TGT_COMPOSE_BOUNDS: + fmt.pad = sel->pad; + fmt.which = sel->which; + ret = vfe_get_format(sd, cfg, &fmt); + if (ret < 0) + return ret; + + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = fmt.format.width; + sel->r.height = fmt.format.height; + break; + case V4L2_SEL_TGT_COMPOSE: + rect = __vfe_get_compose(line, cfg, sel->which); + if (rect == NULL) + return -EINVAL; + + sel->r = *rect; + break; + default: return -EINVAL; + } + else if (sel->pad == MSM_VFE_PAD_SRC) + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + rect = __vfe_get_compose(line, cfg, sel->which); + if (rect == NULL) + return -EINVAL; - sel->r = *compose; - break; - default: - return -EINVAL; - } + sel->r.left = rect->left; + sel->r.top = rect->top; + sel->r.width = rect->width; + sel->r.height = rect->height; + break; + case V4L2_SEL_TGT_CROP: + rect = __vfe_get_crop(line, cfg, sel->which); + if (rect == NULL) + return -EINVAL; + + sel->r = *rect; + break; + default: + return -EINVAL; + } return 0; } @@ -2300,33 +2387,53 @@ int vfe_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_selection *sel) { struct vfe_line *line = v4l2_get_subdevdata(sd); - struct v4l2_rect *compose; - struct v4l2_subdev_format fmt = { 0 }; + struct v4l2_rect *rect; int ret; - if (line->id != VFE_LINE_PIX || sel->pad != MSM_VFE_PAD_SINK) + if (line->id != VFE_LINE_PIX) return -EINVAL; - if (sel->target != V4L2_SEL_TGT_COMPOSE) - return -EINVAL; + if (sel->target == V4L2_SEL_TGT_COMPOSE && + sel->pad == MSM_VFE_PAD_SINK) { + struct v4l2_subdev_selection crop = { 0 }; - compose = __vfe_get_compose(line, cfg, sel->which); - if (compose == NULL) - return -EINVAL; + rect = __vfe_get_compose(line, cfg, sel->which); + if (rect == NULL) + return -EINVAL; + + vfe_try_compose(line, cfg, &sel->r, sel->which); + *rect = sel->r; + + /* Reset source crop selection */ + crop.which = sel->which; + crop.pad = MSM_VFE_PAD_SRC; + crop.target = V4L2_SEL_TGT_CROP; + crop.r = *rect; + ret = vfe_set_selection(sd, cfg, &crop); + } else if (sel->target == V4L2_SEL_TGT_CROP && + sel->pad == MSM_VFE_PAD_SRC) { + struct v4l2_subdev_format fmt = { 0 }; + + rect = __vfe_get_crop(line, cfg, sel->which); + if (rect == NULL) + return -EINVAL; - vfe_try_compose(line, cfg, &sel->r, sel->which); - *compose = sel->r; + vfe_try_crop(line, cfg, &sel->r, sel->which); + *rect = sel->r; - /* Reset source pad format width and height */ - fmt.which = sel->which; - fmt.pad = MSM_VFE_PAD_SRC; - ret = vfe_get_format(sd, cfg, &fmt); - if (ret < 0) - return ret; + /* Reset source pad format width and height */ + fmt.which = sel->which; + fmt.pad = MSM_VFE_PAD_SRC; + ret = vfe_get_format(sd, cfg, &fmt); + if (ret < 0) + return ret; - fmt.format.width = compose->width; - fmt.format.height = compose->height; - ret = vfe_set_format(sd, cfg, &fmt); + fmt.format.width = rect->width; + fmt.format.height = rect->height; + ret = vfe_set_format(sd, cfg, &fmt); + } else { + ret = -EINVAL; + } return ret; } diff --git a/drivers/media/platform/qcom/camss-8x16/vfe.h b/drivers/media/platform/qcom/camss-8x16/vfe.h index 1a0dc19..002e289c 100644 --- a/drivers/media/platform/qcom/camss-8x16/vfe.h +++ b/drivers/media/platform/qcom/camss-8x16/vfe.h @@ -81,6 +81,7 @@ struct vfe_line { struct media_pad pads[MSM_VFE_PADS_NUM]; struct v4l2_mbus_framefmt fmt[MSM_VFE_PADS_NUM]; struct v4l2_rect compose; + struct v4l2_rect crop; struct camss_video video_out; struct vfe_output output; };