16 #include <linux/kernel.h>
17 #include <linux/module.h>
24 #include <linux/slab.h>
34 #define SDO_DEFAULT_STD V4L2_STD_PAL
77 value = (value &
mask) | (old & ~mask);
102 static void sdo_reg_debug(
struct sdo_device *sdev)
104 #define DBGREG(reg_id) \
105 dev_info(sdev->dev, #reg_id " = %08x\n", \
106 sdo_read(sdev, reg_id))
127 static const struct sdo_format *sdo_find_format(
v4l2_std_id id)
131 if (sdo_format[i].
id &
id)
132 return &sdo_format[
i];
147 const struct sdo_format *
fmt;
148 fmt = sdo_find_format(std);
157 *std = sd_to_sdev(sd)->fmt->id;
162 struct v4l2_mbus_framefmt *fmt)
170 fmt->height = sdev->
fmt->height;
177 static int sdo_s_power(
struct v4l2_subdev *sd,
int on)
183 dev_info(dev,
"sdo_s_power(%d)\n", on);
186 ret = pm_runtime_get_sync(dev);
188 ret = pm_runtime_put_sync(dev);
194 static int sdo_streamon(
struct sdo_device *sdev)
209 static int sdo_streamoff(
struct sdo_device *sdev)
216 for (tries = 100; tries; --tries) {
222 dev_err(sdev->
dev,
"failed to stop streaming\n");
223 return tries ? 0 : -
EIO;
226 static int sdo_s_stream(
struct v4l2_subdev *sd,
int on)
229 return on ? sdo_streamon(sdev) : sdo_streamoff(sdev);
233 .s_power = sdo_s_power,
237 .s_std_output = sdo_s_std_output,
238 .g_std_output = sdo_g_std_output,
239 .g_tvnorms_output = sdo_g_tvnorms_output,
240 .g_mbus_fmt = sdo_g_mbus_fmt,
241 .s_stream = sdo_s_stream,
245 .core = &sdo_sd_core_ops,
246 .video = &sdo_sd_video_ops,
249 static int sdo_runtime_suspend(
struct device *dev)
261 static int sdo_runtime_resume(
struct device *dev)
291 .runtime_suspend = sdo_runtime_suspend,
292 .runtime_resume = sdo_runtime_resume,
301 struct clk *sclk_vpll;
306 dev_err(dev,
"not enough memory.\n");
315 dev_err(dev,
"get memory resource failed.\n");
322 dev_err(dev,
"register mapping failed.\n");
330 dev_err(dev,
"get interrupt resource failed.\n");
334 ret = devm_request_irq(&pdev->
dev, res->
start, sdo_irq_handler, 0,
337 dev_err(dev,
"request interrupt failed.\n");
344 if (IS_ERR_OR_NULL(sdev->
sclk_dac)) {
345 dev_err(dev,
"failed to get clock 'sclk_dac'\n");
350 if (IS_ERR_OR_NULL(sdev->
dac)) {
351 dev_err(dev,
"failed to get clock 'dac'\n");
356 if (IS_ERR_OR_NULL(sdev->
dacphy)) {
357 dev_err(dev,
"failed to get clock 'dacphy'\n");
361 sclk_vpll =
clk_get(dev,
"sclk_vpll");
362 if (IS_ERR_OR_NULL(sclk_vpll)) {
363 dev_err(dev,
"failed to get clock 'sclk_vpll'\n");
371 dev_err(dev,
"failed to get clock 'fout_vpll'\n");
378 if (IS_ERR_OR_NULL(sdev->
vdac)) {
379 dev_err(dev,
"failed to get regulator 'vdac'\n");
383 if (IS_ERR_OR_NULL(sdev->
vdet)) {
384 dev_err(dev,
"failed to get regulator 'vdet'\n");
397 strlcpy(sdev->
sd.name,
"s5p-sdo",
sizeof sdev->
sd.name);
427 pm_runtime_disable(&pdev->
dev);