From patchwork Wed Jul 5 08:44:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 107041 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp498255qge; Wed, 5 Jul 2017 01:45:16 -0700 (PDT) X-Received: by 10.98.50.71 with SMTP id y68mr18832060pfy.2.1499244316516; Wed, 05 Jul 2017 01:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499244316; cv=none; d=google.com; s=arc-20160816; b=FypaAnBLkIsBOmy+21mrMrNvoNdPDWPzql2Wc65HiIW3k50ES+pQEklgtamAy6in/4 aXscqrKdl4xl5I51Tb0lhugAQrs7dKi7++uWwR9DKBNKAhFAlKisSNpfqSKVy7fwFpUm 0DOfo6Up34sbWKIyeCNFgrztZeRX3ud8/Jmu0FgfRyLD9+Ub52XMAtzJy46H2L1SfXqu RK82MLoLC0PTb1Q8ChIOhCdU5CmaRYFCBtCH5r+i8rLjBmlUHpxfrHGUfLtPFf/idiFG gsduaA9L1nIgN22aYY8KzJJWQxk05kB+hgBUbrHJDCj50RKWsLNa8rH1fTXzkEQ3lBJp bjPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ygYZUzc1pEp5Bdgt194NiaJkY3VD6hhjnuZnc1kcPWY=; b=PIFYlwxCZ9djkYhi8J0S3fcJ0xGGcx1saGk69JxunadLRBOazfaOajiW5DEFssoyOD 0wKHfwqvI22TP1/C7HE/ZWzdzAqbv/tUV3XR9nUVaUNHhszBx3+3v2r2SaDJckHXAvjL 9t5WtrXvrIY/bAKrFE3CnsDPxwanrP7/YS8hqyDvRhPWl4utRxuVm9mRLSvkHSFWD5ln VLwRrvRwf6RuoSUyPnAQIUf604XfdryD26xIkn7ynPSdEBHdJlkNBIjW8BFy/5snGZZT yHS+Vhedz4LlxeZ/rV5RqGgJC0zxRBHEBD/TontcVPy2tc77QeUSTzvCjON48LklZbUB ZjyA== 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; 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 f6si18253034pln.84.2017.07.05.01.45.16; Wed, 05 Jul 2017 01:45:16 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbdGEIpO (ORCPT + 25 others); Wed, 5 Jul 2017 04:45:14 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:45670 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbdGEIpK (ORCPT ); Wed, 5 Jul 2017 04:45:10 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 5B5C2BF69; Wed, 5 Jul 2017 11:45:07 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, sakari.ailus@linux.intel.com, hansverk@cisco.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Todor Tomov Subject: [PATCH 1/3] [media] ov5645: Set media entity function Date: Wed, 5 Jul 2017 11:44:47 +0300 Message-Id: <1499244289-7791-1-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set media entity function to MEDIA_ENT_F_CAM_SENSOR. Signed-off-by: Todor Tomov --- drivers/media/i2c/ov5645.c | 1 + 1 file changed, 1 insertion(+) -- 1.9.1 diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index d1e844f..bb3dd0d 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -1229,6 +1229,7 @@ static int ov5645_probe(struct i2c_client *client, ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ov5645->pad.flags = MEDIA_PAD_FL_SOURCE; ov5645->sd.dev = &client->dev; + ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad); if (ret < 0) { From patchwork Wed Jul 5 08:44:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 107043 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp498732qge; Wed, 5 Jul 2017 01:45:47 -0700 (PDT) X-Received: by 10.99.44.206 with SMTP id s197mr20103795pgs.116.1499244347145; Wed, 05 Jul 2017 01:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499244347; cv=none; d=google.com; s=arc-20160816; b=n5F8H1O2HYX2bSDrlngmmzmY7JZLVGAgIuAX0Uoy7UIGrTqOHufU4VJemJtrjmOlrv pLSB9aPmX4vhn3g+mVpSkKuCfNPP2IbexfOfVI+7s68Gh7A3Ul42JZmJGw1NtelZU4Ub 4pXHpRIotEauF8SZWx7awpdoxLbNuHjM8ee6UAlDk6Lrrt6fRmHXMVjeFvKn8wLJG8dV Zt2Z7fXtHVPLchIfYbqHMKwk560yUwl9MxguncNT1mLt78BBRDeD9HCBAFwrvBna/SKP a5ekuqFIfnSD7At3+Mt3X81kiyi5e8wLSmLjzU+mqTSRkEciWa8fCITfeGA+1UbVTQG+ mFWg== 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=3LjAwfpfcJbp1OHM7V5BWDkyf8+YlDujNXmErUMo9Vs=; b=yMI/66UDqAFy5Ayyb9mescVuK0PBps0Q3LdS9R81Ts9p7qWyCz5u9JqS+UY4B5N7CB VWT5Ul51tndm7pHnzJcpJaD+MMRC+VWeE3mWTOpIb5Qq86VbwonPe1NnVgFYIc9jaHT2 DVYLf/MtVzdI8hgi1GcleB/VFnGLxmCyigI1c6+CYn8GHF/Kr7FDHfus02EfHgbYmrax QvBjHCmVhTd66H9ACXY+PTuSJB4VSxj2isS1a8oebFLdGjWdqGyq/cwZBSxz1RHGAGd/ udbbdEIq/rkfGhYhVYjLaheQfOyOtD62NTXWIrDxR19HGYcP26MmyxnWiKM80g4/X0Lc 0g2Q== 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; 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 k2si16758379pfh.174.2017.07.05.01.45.46; Wed, 05 Jul 2017 01:45:47 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752498AbdGEIpL (ORCPT + 25 others); Wed, 5 Jul 2017 04:45:11 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:45673 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750841AbdGEIpJ (ORCPT ); Wed, 5 Jul 2017 04:45:09 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id E4452CB9F; Wed, 5 Jul 2017 11:45:07 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, sakari.ailus@linux.intel.com, hansverk@cisco.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Todor Tomov Subject: [PATCH 2/3] [media] ov5645: Add control to export pixel clock frequency Date: Wed, 5 Jul 2017 11:44:48 +0300 Message-Id: <1499244289-7791-2-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499244289-7791-1-git-send-email-todor.tomov@linaro.org> References: <1499244289-7791-1-git-send-email-todor.tomov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add suport for standard V4L2_CID_PIXEL_RATE control. The pixel clock frequency value is specific for each sensor mode so the sensor mode structure is extended to add this. The control is read-only and its value is updated when the sensor mode is changed - on set_format. Signed-off-by: Todor Tomov --- drivers/media/i2c/ov5645.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index bb3dd0d..4583f66 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -80,6 +80,7 @@ struct ov5645_mode_info { u32 height; const struct reg_value *data; u32 data_size; + u32 pixel_clock; }; struct ov5645 { @@ -99,6 +100,7 @@ struct ov5645 { const struct ov5645_mode_info *current_mode; struct v4l2_ctrl_handler ctrls; + struct v4l2_ctrl *pixel_clock; /* Cached register values */ u8 aec_pk_manual; @@ -510,19 +512,22 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd) .width = 1280, .height = 960, .data = ov5645_setting_sxga, - .data_size = ARRAY_SIZE(ov5645_setting_sxga) + .data_size = ARRAY_SIZE(ov5645_setting_sxga), + .pixel_clock = 111440000 }, { .width = 1920, .height = 1080, .data = ov5645_setting_1080p, - .data_size = ARRAY_SIZE(ov5645_setting_1080p) + .data_size = ARRAY_SIZE(ov5645_setting_1080p), + .pixel_clock = 167160000 }, { .width = 2592, .height = 1944, .data = ov5645_setting_full, - .data_size = ARRAY_SIZE(ov5645_setting_full) + .data_size = ARRAY_SIZE(ov5645_setting_full), + .pixel_clock = 167160000 }, }; @@ -969,6 +974,7 @@ static int ov5645_set_format(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *__format; struct v4l2_rect *__crop; const struct ov5645_mode_info *new_mode; + int ret; __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad, format->which); @@ -978,8 +984,14 @@ static int ov5645_set_format(struct v4l2_subdev *sd, __crop->width = new_mode->width; __crop->height = new_mode->height; - if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { + ret = v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock, + new_mode->pixel_clock); + if (ret < 0) + return ret; + ov5645->current_mode = new_mode; + } __format = __ov5645_get_pad_format(ov5645, cfg, format->pad, format->which); @@ -1197,7 +1209,7 @@ static int ov5645_probe(struct i2c_client *client, mutex_init(&ov5645->power_lock); - v4l2_ctrl_handler_init(&ov5645->ctrls, 7); + v4l2_ctrl_handler_init(&ov5645->ctrls, 8); v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, V4L2_CID_SATURATION, -4, 4, 1, 0); v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, @@ -1215,6 +1227,10 @@ static int ov5645_probe(struct i2c_client *client, V4L2_CID_TEST_PATTERN, ARRAY_SIZE(ov5645_test_pattern_menu) - 1, 0, 0, ov5645_test_pattern_menu); + ov5645->pixel_clock = v4l2_ctrl_new_std(&ov5645->ctrls, + &ov5645_ctrl_ops, + V4L2_CID_PIXEL_RATE, + 1, INT_MAX, 1, 1); ov5645->sd.ctrl_handler = &ov5645->ctrls; From patchwork Wed Jul 5 08:44:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 107042 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp498712qge; Wed, 5 Jul 2017 01:45:46 -0700 (PDT) X-Received: by 10.84.232.74 with SMTP id f10mr3435807pln.154.1499244346277; Wed, 05 Jul 2017 01:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499244346; cv=none; d=google.com; s=arc-20160816; b=BUFEJVsMqmIAdYSgeIxSfzwuCFofUk9mkOBwZczAEvcGVLLOvI34H1y2dszIiYRpKm 4qQu1CCXDvk7HfwFMJfBJvZraEMZJXW2xXQYw3er8aKXNfwIhDqY8UFWEsi16AkcYC1C LtvaUxXOi/hm4YVhwdR1csjmkEUxZL+IfuLcVm5gM2OxtaPSb2aJM0ncUcW888+OKkML pf0mNFtpNSo2iDlmw1BIybP2oPepP6Nm3Sek8q0r3mf/V0xScX/g9HxetMfXT7kyZ02p gY0Gsovwq3ttSkIc25hv4sMZxDZl+NZRcuoOdWtqaggSJX37YKC+zVM4Tm44HkStKu2v EvMw== 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=M+OAgF2baw8H3nRJZQiEjKRwrjSInLXXgwkWPJvnQ7U=; b=SPfct8tJlqE54PSLu7s6m9z7vbFuvJFiJLOmN+D4eA2bSv8gbAf/QFGOo+rwvqwWt8 UHatVPik2LX2dBIBK9nfVyFDBmXLv7zUXn9jXzqwt0/QMyX9fE21TrhoUEir5E3f1Hhw /+PJzFNp0ycCLdjkYV+KoQ7crd11zfihjtJGC88GUkwPmuzHQP6BMFp0gt9T3B2eJmGi sev/jpX9BRamP+7ja37jY5Dn8f7i5LgAeLUnhlc9FtGz1i/JJB9biIhKb0TXcTEvuPe4 cuR6GRwyUMBoNXXzXj2eMikQp+DPdz+SNw/HkuzgansjJT8SlRX0OQ2DQ9hYS9ZDgO6J 5Wjw== 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; 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 k2si16758379pfh.174.2017.07.05.01.45.45; Wed, 05 Jul 2017 01:45:46 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752539AbdGEIpN (ORCPT + 25 others); Wed, 5 Jul 2017 04:45:13 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:45675 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbdGEIpK (ORCPT ); Wed, 5 Jul 2017 04:45:10 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 0B1D1CBBA; Wed, 5 Jul 2017 11:45:08 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, sakari.ailus@linux.intel.com, hansverk@cisco.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Todor Tomov Subject: [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency Date: Wed, 5 Jul 2017 11:44:49 +0300 Message-Id: <1499244289-7791-3-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499244289-7791-1-git-send-email-todor.tomov@linaro.org> References: <1499244289-7791-1-git-send-email-todor.tomov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add suport for standard integer menu V4L2_CID_LINK_FREQ control. The CSI2 link frequency value is specific for each sensor mode so the sensor mode structure is extended to add this. The control is made read-only and its value is updated when the sensor mode is changed - on set_format. Signed-off-by: Todor Tomov --- drivers/media/i2c/ov5645.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 4583f66..85622e4 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -81,6 +81,7 @@ struct ov5645_mode_info { const struct reg_value *data; u32 data_size; u32 pixel_clock; + u32 link_freq; }; struct ov5645 { @@ -101,6 +102,7 @@ struct ov5645 { struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl *pixel_clock; + struct v4l2_ctrl *link_freq; /* Cached register values */ u8 aec_pk_manual; @@ -507,27 +509,35 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd) { 0x4202, 0x00 } }; +static const s64 link_freq[] = { + 222880000, + 334320000 +}; + static const struct ov5645_mode_info ov5645_mode_info_data[] = { { .width = 1280, .height = 960, .data = ov5645_setting_sxga, .data_size = ARRAY_SIZE(ov5645_setting_sxga), - .pixel_clock = 111440000 + .pixel_clock = 111440000, + .link_freq = 0 /* an index in link_freq[] */ }, { .width = 1920, .height = 1080, .data = ov5645_setting_1080p, .data_size = ARRAY_SIZE(ov5645_setting_1080p), - .pixel_clock = 167160000 + .pixel_clock = 167160000, + .link_freq = 1 /* an index in link_freq[] */ }, { .width = 2592, .height = 1944, .data = ov5645_setting_full, .data_size = ARRAY_SIZE(ov5645_setting_full), - .pixel_clock = 167160000 + .pixel_clock = 167160000, + .link_freq = 1 /* an index in link_freq[] */ }, }; @@ -990,6 +1000,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd, if (ret < 0) return ret; + ret = v4l2_ctrl_s_ctrl(ov5645->link_freq, + new_mode->link_freq); + if (ret < 0) + return ret; + ov5645->current_mode = new_mode; } @@ -1209,7 +1224,7 @@ static int ov5645_probe(struct i2c_client *client, mutex_init(&ov5645->power_lock); - v4l2_ctrl_handler_init(&ov5645->ctrls, 8); + v4l2_ctrl_handler_init(&ov5645->ctrls, 9); v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, V4L2_CID_SATURATION, -4, 4, 1, 0); v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, @@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client, &ov5645_ctrl_ops, V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); + ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls, + &ov5645_ctrl_ops, + V4L2_CID_LINK_FREQ, + ARRAY_SIZE(link_freq) - 1, + 0, link_freq); + if(ov5645->link_freq) + ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; ov5645->sd.ctrl_handler = &ov5645->ctrls;