From patchwork Thu Apr 11 22:08:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 2432831 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 71070DF230 for ; Thu, 11 Apr 2013 22:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753893Ab3DKWJK (ORCPT ); Thu, 11 Apr 2013 18:09:10 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:38539 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753824Ab3DKWJJ (ORCPT ); Thu, 11 Apr 2013 18:09:09 -0400 Received: by mail-la0-f46.google.com with SMTP id ea20so1958436lab.33 for ; Thu, 11 Apr 2013 15:09:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:to:subject:cc:from:organization:date:mime-version :content-type:content-transfer-encoding:message-id :x-gm-message-state; bh=+9JL/F3stF7+ZEMlXrCgFeNMNlDPwDWc3F6VzegR9TE=; b=GAMImW9yzVOUCXduyOjaEbWCecSHR3RGqprEyu2bnDIXSH5yDLANa5SOWKPCWqaYpL tTvtFrZydUnB5eAWJp0pYIFuhqiLUZsLHX7a+0wbt60bSOXsKqnRKHzU13UWYLQavfmX SIKTliDWFOeQ/gBqDTs/yfiCaS4Yj971izdCROB+uccIn3x4RNgq90LZync7he4Hk6gM Kd/W5tY8GlBZWWZxm7AqyWFRMyaylUCHZcq2TlZexN0ac/zMEYRDXXEeiAJAA3Y5reOZ 3eIJRWkq3/0KtrcFe0SuTahW+RXpCaqAR2q0k6XhN/DaGknVDwFjA/IFpHU7DevPkXOt wFUw== X-Received: by 10.152.104.199 with SMTP id gg7mr4103831lab.14.1365718147683; Thu, 11 Apr 2013 15:09:07 -0700 (PDT) Received: from wasted.dev.rtsoft.ru (ppp91-79-74-243.pppoe.mtu-net.ru. [91.79.74.243]) by mx.google.com with ESMTPS id z10sm2370556lbz.1.2013.04.11.15.09.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 11 Apr 2013 15:09:06 -0700 (PDT) To: mchehab@redhat.com, linux-media@vger.kernel.org Subject: [PATCH v2 2/2] adv7180: add more subdev video ops Cc: vladimir.barinov@cogentembedded.com From: Sergei Shtylyov Organization: Cogent Embedded Date: Fri, 12 Apr 2013 02:08:09 +0400 MIME-Version: 1.0 Message-Id: <201304120208.09564.sergei.shtylyov@cogentembedded.com> X-Gm-Message-State: ALoCoQlNz4jk29tHQYJl+5VM3SJGiSZxzZdf6LKFyyuDJkwJvUx9vIAHaT3BDqrwC8Affq9EivY3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Vladimir Barinov Add subdev video ops for ADV7180 video decoder. This makes decoder usable on the soc-camera drivers. Signed-off-by: Vladimir Barinov Signed-off-by: Sergei Shtylyov --- drivers/media/i2c/adv7180.c | 105 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/drivers/media/i2c/adv7180.c =================================================================== --- linux.orig/drivers/media/i2c/adv7180.c +++ linux/drivers/media/i2c/adv7180.c @@ -1,6 +1,8 @@ /* * adv7180.c Analog Devices ADV7180 video decoder driver * Copyright (c) 2009 Intel Corporation + * Copyright (C) 2013 Cogent Embedded, Inc. + * Copyright (C) 2013 Renesas Solutions Corp. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -128,6 +130,7 @@ struct adv7180_state { v4l2_std_id curr_norm; bool autodetect; u8 input; + struct v4l2_mbus_framefmt fmt; }; #define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \ struct adv7180_state, \ @@ -397,10 +400,112 @@ static void adv7180_exit_controls(struct v4l2_ctrl_handler_free(&state->ctrl_hdl); } +static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, + enum v4l2_mbus_pixelcode *code) +{ + if (index > 0) + return -EINVAL; + + *code = V4L2_MBUS_FMT_YUYV8_2X8; + + return 0; +} + +static int adv7180_try_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct adv7180_state *state = to_state(sd); + + adv7180_querystd(sd, &state->curr_norm); + + fmt->code = V4L2_MBUS_FMT_YUYV8_2X8; + fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; + fmt->field = V4L2_FIELD_INTERLACED; + fmt->width = 720; + fmt->height = state->curr_norm & V4L2_STD_525_60 ? 480 : 576; + + return 0; +} + +static int adv7180_g_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct adv7180_state *state = to_state(sd); + + *fmt = state->fmt; + + return 0; +} + +static int adv7180_s_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct adv7180_state *state = to_state(sd); + + adv7180_try_mbus_fmt(sd, fmt); + state->fmt = *fmt; + + return 0; +} + +static int adv7180_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) +{ + struct adv7180_state *state = to_state(sd); + + adv7180_querystd(sd, &state->curr_norm); + + a->bounds.left = 0; + a->bounds.top = 0; + a->bounds.width = 720; + a->bounds.height = state->curr_norm & V4L2_STD_525_60 ? 480 : 576; + a->defrect = a->bounds; + a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + a->pixelaspect.numerator = 1; + a->pixelaspect.denominator = 1; + + return 0; +} + +static int adv7180_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) +{ + struct adv7180_state *state = to_state(sd); + + adv7180_querystd(sd, &state->curr_norm); + + a->c.left = 0; + a->c.top = 0; + a->c.width = 720; + a->c.height = state->curr_norm & V4L2_STD_525_60 ? 480 : 576; + a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + return 0; +} + +static int adv7180_g_mbus_config(struct v4l2_subdev *sd, + struct v4l2_mbus_config *cfg) +{ + /* + * The ADV7180 sensor supports BT.601/656 output modes. + * The BT.656 is default and not yet configurable by s/w. + */ + cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | + V4L2_MBUS_DATA_ACTIVE_HIGH; + cfg->type = V4L2_MBUS_BT656; + + return 0; +} + static const struct v4l2_subdev_video_ops adv7180_video_ops = { .querystd = adv7180_querystd, .g_input_status = adv7180_g_input_status, .s_routing = adv7180_s_routing, + .enum_mbus_fmt = adv7180_enum_mbus_fmt, + .try_mbus_fmt = adv7180_try_mbus_fmt, + .g_mbus_fmt = adv7180_g_mbus_fmt, + .s_mbus_fmt = adv7180_s_mbus_fmt, + .cropcap = adv7180_cropcap, + .g_crop = adv7180_g_crop, + .g_mbus_config = adv7180_g_mbus_config, }; static const struct v4l2_subdev_core_ops adv7180_core_ops = {