Lines Matching +full:sd +full:- +full:lines

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for AK8813 / AK8814 TV-ecoders from Asahi Kasei Microsystems Co., Ltd. (AKM)
16 #include <media/v4l2-common.h>
17 #include <media/v4l2-device.h>
31 unsigned int lines; member
61 static int ak881x_g_register(struct v4l2_subdev *sd, in ak881x_g_register() argument
64 struct i2c_client *client = v4l2_get_subdevdata(sd); in ak881x_g_register()
66 if (reg->reg > 0x26) in ak881x_g_register()
67 return -EINVAL; in ak881x_g_register()
69 reg->size = 1; in ak881x_g_register()
70 reg->val = reg_read(client, reg->reg); in ak881x_g_register()
72 if (reg->val > 0xffff) in ak881x_g_register()
73 return -EIO; in ak881x_g_register()
78 static int ak881x_s_register(struct v4l2_subdev *sd, in ak881x_s_register() argument
81 struct i2c_client *client = v4l2_get_subdevdata(sd); in ak881x_s_register()
83 if (reg->reg > 0x26) in ak881x_s_register()
84 return -EINVAL; in ak881x_s_register()
86 if (reg_write(client, reg->reg, reg->val) < 0) in ak881x_s_register()
87 return -EIO; in ak881x_s_register()
93 static int ak881x_fill_fmt(struct v4l2_subdev *sd, in ak881x_fill_fmt() argument
97 struct v4l2_mbus_framefmt *mf = &format->format; in ak881x_fill_fmt()
98 struct i2c_client *client = v4l2_get_subdevdata(sd); in ak881x_fill_fmt()
101 if (format->pad) in ak881x_fill_fmt()
102 return -EINVAL; in ak881x_fill_fmt()
104 v4l_bound_align_image(&mf->width, 0, 720, 2, in ak881x_fill_fmt()
105 &mf->height, 0, ak881x->lines, 1, 0); in ak881x_fill_fmt()
106 mf->field = V4L2_FIELD_INTERLACED; in ak881x_fill_fmt()
107 mf->code = MEDIA_BUS_FMT_YUYV8_2X8; in ak881x_fill_fmt()
108 mf->colorspace = V4L2_COLORSPACE_SMPTE170M; in ak881x_fill_fmt()
113 static int ak881x_enum_mbus_code(struct v4l2_subdev *sd, in ak881x_enum_mbus_code() argument
117 if (code->pad || code->index) in ak881x_enum_mbus_code()
118 return -EINVAL; in ak881x_enum_mbus_code()
120 code->code = MEDIA_BUS_FMT_YUYV8_2X8; in ak881x_enum_mbus_code()
124 static int ak881x_get_selection(struct v4l2_subdev *sd, in ak881x_get_selection() argument
128 struct i2c_client *client = v4l2_get_subdevdata(sd); in ak881x_get_selection()
131 if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) in ak881x_get_selection()
132 return -EINVAL; in ak881x_get_selection()
134 switch (sel->target) { in ak881x_get_selection()
136 sel->r.left = 0; in ak881x_get_selection()
137 sel->r.top = 0; in ak881x_get_selection()
138 sel->r.width = 720; in ak881x_get_selection()
139 sel->r.height = ak881x->lines; in ak881x_get_selection()
142 return -EINVAL; in ak881x_get_selection()
146 static int ak881x_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) in ak881x_s_std_output() argument
148 struct i2c_client *client = v4l2_get_subdevdata(sd); in ak881x_s_std_output()
154 ak881x->lines = 480; in ak881x_s_std_output()
157 ak881x->lines = 480; in ak881x_s_std_output()
160 ak881x->lines = 480; in ak881x_s_std_output()
163 ak881x->lines = 480; in ak881x_s_std_output()
166 ak881x->lines = 576; in ak881x_s_std_output()
169 return -EINVAL; in ak881x_s_std_output()
177 static int ak881x_s_stream(struct v4l2_subdev *sd, int enable) in ak881x_s_stream() argument
179 struct i2c_client *client = v4l2_get_subdevdata(sd); in ak881x_s_stream()
184 /* For colour-bar testing set bit 6 of AK881X_VIDEO_PROCESS1 */ in ak881x_s_stream()
186 if (ak881x->pdata->flags & AK881X_COMPONENT) in ak881x_s_stream()
192 dev_dbg(&client->dev, "chip status 0x%x\n", in ak881x_s_stream()
197 dev_dbg(&client->dev, "chip status 0x%x\n", in ak881x_s_stream()
231 struct i2c_adapter *adapter = client->adapter; in ak881x_probe()
236 dev_warn(&adapter->dev, in ak881x_probe()
237 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); in ak881x_probe()
238 return -EIO; in ak881x_probe()
241 ak881x = devm_kzalloc(&client->dev, sizeof(*ak881x), GFP_KERNEL); in ak881x_probe()
243 return -ENOMEM; in ak881x_probe()
245 v4l2_i2c_subdev_init(&ak881x->subdev, client, &ak881x_subdev_ops); in ak881x_probe()
254 dev_err(&client->dev, in ak881x_probe()
256 return -ENODEV; in ak881x_probe()
259 ak881x->revision = reg_read(client, AK881X_DEVICE_REVISION); in ak881x_probe()
260 ak881x->pdata = client->dev.platform_data; in ak881x_probe()
262 if (ak881x->pdata) { in ak881x_probe()
263 if (ak881x->pdata->flags & AK881X_FIELD) in ak881x_probe()
268 switch (ak881x->pdata->flags & AK881X_IF_MODE_MASK) { in ak881x_probe()
280 dev_dbg(&client->dev, "IF mode %x\n", ifmode); in ak881x_probe()
284 * "black" lines on, e.g., SuperH VOU, whose default value of 20 in ak881x_probe()
290 /* Hardware default: NTSC-M */ in ak881x_probe()
291 ak881x->lines = 480; in ak881x_probe()
293 dev_info(&client->dev, "Detected an ak881x chip ID %x, revision %x\n", in ak881x_probe()
294 data, ak881x->revision); in ak881x_probe()
303 v4l2_device_unregister_subdev(&ak881x->subdev); in ak881x_remove()
324 MODULE_DESCRIPTION("TV-output driver for ak8813/ak8814");