1 // SPDX-License-Identifier: GPL-2.0
3 * Support for Medifield PNW Camera Imaging ISP subsystem.
5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
7 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
21 #include <media/v4l2-event.h>
22 #include <media/v4l2-mediabus.h>
23 #include "atomisp_internal.h"
24 #include "atomisp_tpg.h"
26 static int tpg_s_stream(struct v4l2_subdev *sd, int enable)
31 static int tpg_get_fmt(struct v4l2_subdev *sd,
32 struct v4l2_subdev_state *sd_state,
33 struct v4l2_subdev_format *format)
39 static int tpg_set_fmt(struct v4l2_subdev *sd,
40 struct v4l2_subdev_state *sd_state,
41 struct v4l2_subdev_format *format)
43 struct v4l2_mbus_framefmt *fmt = &format->format;
47 /* only raw8 grbg is supported by TPG */
48 fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8;
49 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
50 sd_state->pads->try_fmt = *fmt;
56 static int tpg_log_status(struct v4l2_subdev *sd)
62 static int tpg_s_power(struct v4l2_subdev *sd, int on)
67 static int tpg_enum_mbus_code(struct v4l2_subdev *sd,
68 struct v4l2_subdev_state *sd_state,
69 struct v4l2_subdev_mbus_code_enum *code)
75 static int tpg_enum_frame_size(struct v4l2_subdev *sd,
76 struct v4l2_subdev_state *sd_state,
77 struct v4l2_subdev_frame_size_enum *fse)
83 static int tpg_enum_frame_ival(struct v4l2_subdev *sd,
84 struct v4l2_subdev_state *sd_state,
85 struct v4l2_subdev_frame_interval_enum *fie)
91 static const struct v4l2_subdev_video_ops tpg_video_ops = {
92 .s_stream = tpg_s_stream,
95 static const struct v4l2_subdev_core_ops tpg_core_ops = {
96 .log_status = tpg_log_status,
97 .s_power = tpg_s_power,
100 static const struct v4l2_subdev_pad_ops tpg_pad_ops = {
101 .enum_mbus_code = tpg_enum_mbus_code,
102 .enum_frame_size = tpg_enum_frame_size,
103 .enum_frame_interval = tpg_enum_frame_ival,
104 .get_fmt = tpg_get_fmt,
105 .set_fmt = tpg_set_fmt,
108 static const struct v4l2_subdev_ops tpg_ops = {
109 .core = &tpg_core_ops,
110 .video = &tpg_video_ops,
114 void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg)
116 media_entity_cleanup(&tpg->sd.entity);
117 v4l2_device_unregister_subdev(&tpg->sd);
120 int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg,
121 struct v4l2_device *vdev)
124 /* Register the subdev and video nodes. */
125 ret = v4l2_device_register_subdev(vdev, &tpg->sd);
132 atomisp_tpg_unregister_entities(tpg);
136 void atomisp_tpg_cleanup(struct atomisp_device *isp)
140 int atomisp_tpg_init(struct atomisp_device *isp)
142 struct atomisp_tpg_device *tpg = &isp->tpg;
143 struct v4l2_subdev *sd = &tpg->sd;
144 struct media_pad *pads = tpg->pads;
145 struct media_entity *me = &sd->entity;
149 v4l2_subdev_init(sd, &tpg_ops);
150 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
151 strscpy(sd->name, "tpg_subdev", sizeof(sd->name));
152 v4l2_set_subdevdata(sd, tpg);
154 pads[0].flags = MEDIA_PAD_FL_SINK;
155 me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
157 ret = media_entity_pads_init(me, 1, pads);
162 atomisp_tpg_cleanup(isp);