2 * Support for Medifield PNW Camera Imaging ISP subsystem.
4 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <media/v4l2-event.h>
25 #include <media/v4l2-mediabus.h>
26 #include "atomisp_internal.h"
27 #include "atomisp_tpg.h"
29 static int tpg_s_stream(struct v4l2_subdev *sd, int enable)
34 static int tpg_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
40 static int tpg_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
46 static int tpg_get_fmt(struct v4l2_subdev *sd,
47 struct v4l2_subdev_pad_config *cfg,
48 struct v4l2_subdev_format *format)
54 static int tpg_set_fmt(struct v4l2_subdev *sd,
55 struct v4l2_subdev_pad_config *cfg,
56 struct v4l2_subdev_format *format)
58 struct v4l2_mbus_framefmt *fmt = &format->format;
62 /* only raw8 grbg is supported by TPG */
63 fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8;
64 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
71 static int tpg_log_status(struct v4l2_subdev *sd)
77 static int tpg_s_power(struct v4l2_subdev *sd, int on)
82 static int tpg_enum_mbus_code(struct v4l2_subdev *sd,
83 struct v4l2_subdev_pad_config *cfg,
84 struct v4l2_subdev_mbus_code_enum *code)
90 static int tpg_enum_frame_size(struct v4l2_subdev *sd,
91 struct v4l2_subdev_pad_config *cfg,
92 struct v4l2_subdev_frame_size_enum *fse)
98 static int tpg_enum_frame_ival(struct v4l2_subdev *sd,
99 struct v4l2_subdev_pad_config *cfg,
100 struct v4l2_subdev_frame_interval_enum *fie)
106 static const struct v4l2_subdev_video_ops tpg_video_ops = {
107 .s_stream = tpg_s_stream,
108 .g_parm = tpg_g_parm,
109 .s_parm = tpg_s_parm,
112 static const struct v4l2_subdev_core_ops tpg_core_ops = {
113 .log_status = tpg_log_status,
114 .s_power = tpg_s_power,
117 static const struct v4l2_subdev_pad_ops tpg_pad_ops = {
118 .enum_mbus_code = tpg_enum_mbus_code,
119 .enum_frame_size = tpg_enum_frame_size,
120 .enum_frame_interval = tpg_enum_frame_ival,
121 .get_fmt = tpg_get_fmt,
122 .set_fmt = tpg_set_fmt,
125 static const struct v4l2_subdev_ops tpg_ops = {
126 .core = &tpg_core_ops,
127 .video = &tpg_video_ops,
131 void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg)
133 media_entity_cleanup(&tpg->sd.entity);
134 v4l2_device_unregister_subdev(&tpg->sd);
137 int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg,
138 struct v4l2_device *vdev)
141 /* Register the subdev and video nodes. */
142 ret = v4l2_device_register_subdev(vdev, &tpg->sd);
149 atomisp_tpg_unregister_entities(tpg);
153 void atomisp_tpg_cleanup(struct atomisp_device *isp)
158 int atomisp_tpg_init(struct atomisp_device *isp)
160 struct atomisp_tpg_device *tpg = &isp->tpg;
161 struct v4l2_subdev *sd = &tpg->sd;
162 struct media_pad *pads = tpg->pads;
163 struct media_entity *me = &sd->entity;
167 v4l2_subdev_init(sd, &tpg_ops);
168 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
169 strcpy(sd->name, "tpg_subdev");
170 v4l2_set_subdevdata(sd, tpg);
172 pads[0].flags = MEDIA_PAD_FL_SINK;
173 me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
175 ret = media_entity_pads_init(me, 1, pads);
180 atomisp_tpg_cleanup(isp);