]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/staging/media/atomisp/pci/atomisp2/atomisp_tpg.c
media: staging: atomisp: Remove FSF snail address
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / atomisp_tpg.c
CommitLineData
a49d2536
AC
1/*
2 * Support for Medifield PNW Camera Imaging ISP subsystem.
3 *
4 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
5 *
6 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
7 *
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.
11 *
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.
16 *
a49d2536
AC
17 *
18 */
19
20#include <media/v4l2-event.h>
21#include <media/v4l2-mediabus.h>
22#include "atomisp_internal.h"
23#include "atomisp_tpg.h"
24
25static int tpg_s_stream(struct v4l2_subdev *sd, int enable)
26{
27 return 0;
28}
29
30static int tpg_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
31{
32 /*to fake*/
33 return 0;
34}
35
36static int tpg_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
37{
38 /*to fake*/
39 return 0;
40}
41
42static int tpg_get_fmt(struct v4l2_subdev *sd,
43 struct v4l2_subdev_pad_config *cfg,
44 struct v4l2_subdev_format *format)
45{
46 /*to fake*/
47 return 0;
48}
49
50static int tpg_set_fmt(struct v4l2_subdev *sd,
51 struct v4l2_subdev_pad_config *cfg,
52 struct v4l2_subdev_format *format)
53{
54 struct v4l2_mbus_framefmt *fmt = &format->format;
54221e72 55
a49d2536
AC
56 if (format->pad)
57 return -EINVAL;
58 /* only raw8 grbg is supported by TPG */
59 fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8;
60 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
61 cfg->try_fmt = *fmt;
62 return 0;
63 }
64 return 0;
65}
66
67static int tpg_log_status(struct v4l2_subdev *sd)
68{
69 /*to fake*/
70 return 0;
71}
72
73static int tpg_s_power(struct v4l2_subdev *sd, int on)
74{
75 return 0;
76}
77
78static int tpg_enum_mbus_code(struct v4l2_subdev *sd,
79 struct v4l2_subdev_pad_config *cfg,
80 struct v4l2_subdev_mbus_code_enum *code)
81{
82 /*to fake*/
83 return 0;
84}
85
86static int tpg_enum_frame_size(struct v4l2_subdev *sd,
87 struct v4l2_subdev_pad_config *cfg,
88 struct v4l2_subdev_frame_size_enum *fse)
89{
90 /*to fake*/
91 return 0;
92}
93
94static int tpg_enum_frame_ival(struct v4l2_subdev *sd,
95 struct v4l2_subdev_pad_config *cfg,
96 struct v4l2_subdev_frame_interval_enum *fie)
97{
98 /*to fake*/
99 return 0;
100}
101
102static const struct v4l2_subdev_video_ops tpg_video_ops = {
103 .s_stream = tpg_s_stream,
104 .g_parm = tpg_g_parm,
105 .s_parm = tpg_s_parm,
106};
107
108static const struct v4l2_subdev_core_ops tpg_core_ops = {
109 .log_status = tpg_log_status,
110 .s_power = tpg_s_power,
111};
112
113static const struct v4l2_subdev_pad_ops tpg_pad_ops = {
114 .enum_mbus_code = tpg_enum_mbus_code,
115 .enum_frame_size = tpg_enum_frame_size,
116 .enum_frame_interval = tpg_enum_frame_ival,
117 .get_fmt = tpg_get_fmt,
118 .set_fmt = tpg_set_fmt,
119};
120
121static const struct v4l2_subdev_ops tpg_ops = {
122 .core = &tpg_core_ops,
123 .video = &tpg_video_ops,
124 .pad = &tpg_pad_ops,
125};
126
127void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg)
128{
129 media_entity_cleanup(&tpg->sd.entity);
130 v4l2_device_unregister_subdev(&tpg->sd);
131}
132
133int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg,
134 struct v4l2_device *vdev)
135{
136 int ret;
137 /* Register the subdev and video nodes. */
138 ret = v4l2_device_register_subdev(vdev, &tpg->sd);
139 if (ret < 0)
140 goto error;
141
142 return 0;
143
144error:
145 atomisp_tpg_unregister_entities(tpg);
146 return ret;
147}
148
149void atomisp_tpg_cleanup(struct atomisp_device *isp)
150{
151
152}
153
154int atomisp_tpg_init(struct atomisp_device *isp)
155{
156 struct atomisp_tpg_device *tpg = &isp->tpg;
157 struct v4l2_subdev *sd = &tpg->sd;
158 struct media_pad *pads = tpg->pads;
159 struct media_entity *me = &sd->entity;
160 int ret;
161
162 tpg->isp = isp;
163 v4l2_subdev_init(sd, &tpg_ops);
164 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
165 strcpy(sd->name, "tpg_subdev");
166 v4l2_set_subdevdata(sd, tpg);
167
168 pads[0].flags = MEDIA_PAD_FL_SINK;
169 me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
170
171 ret = media_entity_pads_init(me, 1, pads);
172 if (ret < 0)
173 goto fail;
174 return 0;
175fail:
176 atomisp_tpg_cleanup(isp);
177 return ret;
178}