From patchwork Mon Feb 5 14:29:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Echtler X-Patchwork-Id: 10200537 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 8909C601A1 for ; Mon, 5 Feb 2018 14:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79FF428405 for ; Mon, 5 Feb 2018 14:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F08828479; Mon, 5 Feb 2018 14:37:43 +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 9E5D428682 for ; Mon, 5 Feb 2018 14:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbeBEOhi (ORCPT ); Mon, 5 Feb 2018 09:37:38 -0500 Received: from butterbrot.org ([176.9.106.16]:41564 "EHLO butterbrot.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752808AbeBEOhb (ORCPT ); Mon, 5 Feb 2018 09:37:31 -0500 Received: from flunder.scc.uni-weimar.de (anna125.medien.uni-weimar.de [141.54.178.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by butterbrot.org (Postfix) with ESMTPSA id 4F0794AE040D; Mon, 5 Feb 2018 15:30:08 +0100 (CET) From: Florian Echtler To: linux-media@vger.kernel.org, hverkuil@xs4all.nl Cc: linux-input@vger.kernel.org, modin@yuri.at, Florian Echtler Subject: [PATCH 4/5] add V4L2 control functions Date: Mon, 5 Feb 2018 15:29:40 +0100 Message-Id: <1517840981-12280-5-git-send-email-floe@butterbrot.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517840981-12280-1-git-send-email-floe@butterbrot.org> References: <1517840981-12280-1-git-send-email-floe@butterbrot.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Florian Echtler --- drivers/input/touchscreen/sur40.c | 114 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 63c7264b..c4b7cf1 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -953,6 +953,119 @@ static int sur40_vidioc_g_fmt(struct file *file, void *priv, return 0; } + +static int sur40_vidioc_queryctrl(struct file *file, void *fh, + struct v4l2_queryctrl *qc) +{ + + switch (qc->id) { + case V4L2_CID_BRIGHTNESS: + qc->flags = 0; + sprintf(qc->name, "Brightness"); + qc->type = V4L2_CTRL_TYPE_INTEGER; + qc->minimum = SUR40_BRIGHTNESS_MIN; + qc->default_value = SUR40_BRIGHTNESS_DEF; + qc->maximum = SUR40_BRIGHTNESS_MAX; + qc->step = 8; + return 0; + case V4L2_CID_CONTRAST: + qc->flags = 0; + sprintf(qc->name, "Contrast"); + qc->type = V4L2_CTRL_TYPE_INTEGER; + qc->minimum = SUR40_CONTRAST_MIN; + qc->default_value = SUR40_CONTRAST_DEF; + qc->maximum = SUR40_CONTRAST_MAX; + qc->step = 1; + return 0; + case V4L2_CID_GAIN: + qc->flags = 0; + sprintf(qc->name, "Gain"); + qc->type = V4L2_CTRL_TYPE_INTEGER; + qc->minimum = SUR40_GAIN_MIN; + qc->default_value = SUR40_GAIN_DEF; + qc->maximum = SUR40_GAIN_MAX; + qc->step = 1; + return 0; + case V4L2_CID_BACKLIGHT_COMPENSATION: + qc->flags = 0; + sprintf(qc->name, "Preprocessor"); + qc->type = V4L2_CTRL_TYPE_INTEGER; + qc->minimum = SUR40_BACKLIGHT_MIN; + qc->default_value = SUR40_BACKLIGHT_DEF; + qc->maximum = SUR40_BACKLIGHT_MAX; + qc->step = 1; + return 0; + default: + qc->flags = V4L2_CTRL_FLAG_DISABLED; + return -EINVAL; + } +} + +static int sur40_vidioc_g_ctrl(struct file *file, void *fh, + struct v4l2_control *ctrl) +{ + + switch (ctrl->id) { + case V4L2_CID_BRIGHTNESS: + ctrl->value = sur40_v4l2_brightness; + return 0; + case V4L2_CID_CONTRAST: + ctrl->value = sur40_v4l2_contrast; + return 0; + case V4L2_CID_GAIN: + ctrl->value = sur40_v4l2_gain; + return 0; + case V4L2_CID_BACKLIGHT_COMPENSATION: + ctrl->value = sur40_v4l2_backlight; + return 0; + default: + return -EINVAL; + } +} + +static int sur40_vidioc_s_ctrl(struct file *file, void *fh, + struct v4l2_control *ctrl) +{ + u8 value = 0; + struct sur40_state *sur40 = video_drvdata(file); + + switch (ctrl->id) { + case V4L2_CID_BRIGHTNESS: + sur40_v4l2_brightness = ctrl->value; + if (sur40_v4l2_brightness < SUR40_BRIGHTNESS_MIN) + sur40_v4l2_brightness = SUR40_BRIGHTNESS_MIN; + else if (sur40_v4l2_brightness > SUR40_BRIGHTNESS_MAX) + sur40_v4l2_brightness = SUR40_BRIGHTNESS_MAX; + sur40_set_irlevel(sur40, sur40_v4l2_brightness); + return 0; + case V4L2_CID_CONTRAST: + sur40_v4l2_contrast = ctrl->value; + if (sur40_v4l2_contrast < SUR40_CONTRAST_MIN) + sur40_v4l2_contrast = SUR40_CONTRAST_MIN; + else if (sur40_v4l2_contrast > SUR40_CONTRAST_MAX) + sur40_v4l2_contrast = SUR40_CONTRAST_MAX; + value = (sur40_v4l2_contrast << 4) + sur40_v4l2_gain; + sur40_set_vsvideo(sur40, value); + return 0; + case V4L2_CID_GAIN: + sur40_v4l2_gain = ctrl->value; + if (sur40_v4l2_gain < SUR40_GAIN_MIN) + sur40_v4l2_gain = SUR40_GAIN_MIN; + else if (sur40_v4l2_gain > SUR40_GAIN_MAX) + sur40_v4l2_gain = SUR40_GAIN_MAX; + value = (sur40_v4l2_contrast << 4) + sur40_v4l2_gain; + sur40_set_vsvideo(sur40, value); + return 0; + case V4L2_CID_BACKLIGHT_COMPENSATION: + sur40_v4l2_backlight = ctrl->value; + sur40_set_preprocessor(sur40, sur40_v4l2_backlight); + return 0; + default: + return -EINVAL; + } +} + + static int sur40_ioctl_parm(struct file *file, void *priv, struct v4l2_streamparm *p) { @@ -1071,6 +1181,10 @@ static const struct v4l2_ioctl_ops sur40_video_ioctl_ops = { .vidioc_g_input = sur40_vidioc_g_input, .vidioc_s_input = sur40_vidioc_s_input, + .vidioc_queryctrl = sur40_vidioc_queryctrl, + .vidioc_g_ctrl = sur40_vidioc_g_ctrl, + .vidioc_s_ctrl = sur40_vidioc_s_ctrl, + .vidioc_reqbufs = vb2_ioctl_reqbufs, .vidioc_create_bufs = vb2_ioctl_create_bufs, .vidioc_querybuf = vb2_ioctl_querybuf,