Lines Matching +full:pci +full:- +full:sig
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2021-2023 Digiteq Automotive
26 voutdev = vindev->mgbdev->vout[i]; in loopin_cnt()
30 config = mgb4_read_reg(&voutdev->mgbdev->video, in loopin_cnt()
31 voutdev->config->regs.config); in loopin_cnt()
32 if ((config & 0xc) >> 2 == vindev->config->id) in loopin_cnt()
43 mutex_lock(dev->lock); in is_busy()
44 ret = vb2_is_busy(dev->queue); in is_busy()
45 mutex_unlock(dev->lock); in is_busy()
58 return sprintf(buf, "%d\n", voutdev->config->id); in output_id_show()
66 u32 config = mgb4_read_reg(&voutdev->mgbdev->video, in video_source_show()
67 voutdev->config->regs.config); in video_source_show()
77 * As we do not want to lock all the video devices at the same time, a two-stage
79 * a global (PCI device) variable "io_reconfig" atomically checked/set when
90 struct mgb4_dev *mgbdev = voutdev->mgbdev; in video_source_store()
101 return -EINVAL; in video_source_store()
103 if (test_and_set_bit(0, &mgbdev->io_reconfig)) in video_source_store()
104 return -EBUSY; in video_source_store()
106 ret = -EBUSY; in video_source_store()
108 if (mgbdev->vin[i] && is_busy(&mgbdev->vin[i]->vdev)) in video_source_store()
111 if (mgbdev->vout[i] && is_busy(&mgbdev->vout[i]->vdev)) in video_source_store()
114 config = mgb4_read_reg(&mgbdev->video, voutdev->config->regs.config); in video_source_store()
117 loopin_old = mgbdev->vin[(config & 0xc) >> 2]; in video_source_store()
120 loopin_new = mgbdev->vin[val]; in video_source_store()
123 mgb4_mask_reg(&mgbdev->video, loopin_old->config->regs.config, in video_source_store()
126 mgb4_mask_reg(&mgbdev->video, loopin_new->config->regs.config, in video_source_store()
129 if (val == voutdev->config->id + MGB4_VIN_DEVICES) in video_source_store()
130 mgb4_write_reg(&mgbdev->video, voutdev->config->regs.config, in video_source_store()
133 mgb4_write_reg(&mgbdev->video, voutdev->config->regs.config, in video_source_store()
136 mgb4_mask_reg(&mgbdev->video, voutdev->config->regs.config, 0xc, in video_source_store()
141 clear_bit(0, &mgbdev->io_reconfig); in video_source_store()
151 u32 config = mgb4_read_reg(&voutdev->mgbdev->video, in display_width_show()
152 voutdev->config->regs.resolution); in display_width_show()
170 return -EINVAL; in display_width_store()
172 mutex_lock(voutdev->vdev.lock); in display_width_store()
173 if (vb2_is_busy(voutdev->vdev.queue)) { in display_width_store()
174 mutex_unlock(voutdev->vdev.lock); in display_width_store()
175 return -EBUSY; in display_width_store()
178 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.resolution, in display_width_store()
181 mutex_unlock(voutdev->vdev.lock); in display_width_store()
191 u32 config = mgb4_read_reg(&voutdev->mgbdev->video, in display_height_show()
192 voutdev->config->regs.resolution); in display_height_show()
210 return -EINVAL; in display_height_store()
212 mutex_lock(voutdev->vdev.lock); in display_height_store()
213 if (vb2_is_busy(voutdev->vdev.queue)) { in display_height_store()
214 mutex_unlock(voutdev->vdev.lock); in display_height_store()
215 return -EBUSY; in display_height_store()
218 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.resolution, in display_height_store()
221 mutex_unlock(voutdev->vdev.lock); in display_height_store()
231 u32 period = mgb4_read_reg(&voutdev->mgbdev->video, in frame_rate_show()
232 voutdev->config->regs.frame_limit); in frame_rate_show()
255 mgb4_write_reg(&voutdev->mgbdev->video, in frame_rate_store()
256 voutdev->config->regs.frame_limit, limit); in frame_rate_store()
266 u32 sig = mgb4_read_reg(&voutdev->mgbdev->video, in hsync_width_show() local
267 voutdev->config->regs.hsync); in hsync_width_show()
269 return sprintf(buf, "%u\n", (sig & 0x00FF0000) >> 16); in hsync_width_show()
289 return -EINVAL; in hsync_width_store()
291 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.hsync, in hsync_width_store()
302 u32 sig = mgb4_read_reg(&voutdev->mgbdev->video, in vsync_width_show() local
303 voutdev->config->regs.vsync); in vsync_width_show()
305 return sprintf(buf, "%u\n", (sig & 0x00FF0000) >> 16); in vsync_width_show()
325 return -EINVAL; in vsync_width_store()
327 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.vsync, in vsync_width_store()
338 u32 sig = mgb4_read_reg(&voutdev->mgbdev->video, in hback_porch_show() local
339 voutdev->config->regs.hsync); in hback_porch_show()
341 return sprintf(buf, "%u\n", (sig & 0x0000FF00) >> 8); in hback_porch_show()
361 return -EINVAL; in hback_porch_store()
363 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.hsync, in hback_porch_store()
374 u32 sig = mgb4_read_reg(&voutdev->mgbdev->video, in vback_porch_show() local
375 voutdev->config->regs.vsync); in vback_porch_show()
377 return sprintf(buf, "%u\n", (sig & 0x0000FF00) >> 8); in vback_porch_show()
397 return -EINVAL; in vback_porch_store()
399 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.vsync, in vback_porch_store()
410 u32 sig = mgb4_read_reg(&voutdev->mgbdev->video, in hfront_porch_show() local
411 voutdev->config->regs.hsync); in hfront_porch_show()
413 return sprintf(buf, "%u\n", (sig & 0x000000FF)); in hfront_porch_show()
433 return -EINVAL; in hfront_porch_store()
435 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.hsync, in hfront_porch_store()
446 u32 sig = mgb4_read_reg(&voutdev->mgbdev->video, in vfront_porch_show() local
447 voutdev->config->regs.vsync); in vfront_porch_show()
449 return sprintf(buf, "%u\n", (sig & 0x000000FF)); in vfront_porch_show()
469 return -EINVAL; in vfront_porch_store()
471 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.vsync, in vfront_porch_store()
484 u32 config = mgb4_read_reg(&voutdev->mgbdev->video, in hsync_polarity_show()
485 voutdev->config->regs.hsync); in hsync_polarity_show()
507 return -EINVAL; in hsync_polarity_store()
509 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.hsync, in hsync_polarity_store()
520 u32 config = mgb4_read_reg(&voutdev->mgbdev->video, in vsync_polarity_show()
521 voutdev->config->regs.vsync); in vsync_polarity_show()
543 return -EINVAL; in vsync_polarity_store()
545 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.vsync, in vsync_polarity_store()
556 u32 config = mgb4_read_reg(&voutdev->mgbdev->video, in de_polarity_show()
557 voutdev->config->regs.vsync); in de_polarity_show()
579 return -EINVAL; in de_polarity_store()
581 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.vsync, in de_polarity_store()
594 mutex_lock(&voutdev->mgbdev->i2c_lock); in fpdl3_output_width_show()
595 ret = mgb4_i2c_read_byte(&voutdev->ser, 0x5B); in fpdl3_output_width_show()
596 mutex_unlock(&voutdev->mgbdev->i2c_lock); in fpdl3_output_width_show()
598 return -EIO; in fpdl3_output_width_show()
608 return -EINVAL; in fpdl3_output_width_show()
613 * FPD-Link width change is expected to be called on live streams. Video device
641 return -EINVAL; in fpdl3_output_width_store()
644 mutex_lock(&voutdev->mgbdev->i2c_lock); in fpdl3_output_width_store()
645 ret = mgb4_i2c_mask_byte(&voutdev->ser, 0x5B, 0x03, i2c_data); in fpdl3_output_width_store()
646 mutex_unlock(&voutdev->mgbdev->i2c_lock); in fpdl3_output_width_store()
648 return -EIO; in fpdl3_output_width_store()
659 return sprintf(buf, "%u\n", voutdev->freq); in pclk_frequency_show()
676 mutex_lock(voutdev->vdev.lock); in pclk_frequency_store()
677 if (vb2_is_busy(voutdev->vdev.queue)) { in pclk_frequency_store()
678 mutex_unlock(voutdev->vdev.lock); in pclk_frequency_store()
679 return -EBUSY; in pclk_frequency_store()
683 voutdev->freq = mgb4_cmt_set_vout_freq(voutdev, val >> dp) << dp; in pclk_frequency_store()
685 mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.config, in pclk_frequency_store()
687 mutex_lock(&voutdev->mgbdev->i2c_lock); in pclk_frequency_store()
688 ret = mgb4_i2c_mask_byte(&voutdev->ser, 0x4F, 1 << 6, ((~dp) & 1) << 6); in pclk_frequency_store()
689 mutex_unlock(&voutdev->mgbdev->i2c_lock); in pclk_frequency_store()
691 mutex_unlock(voutdev->vdev.lock); in pclk_frequency_store()
693 return (ret < 0) ? -EIO : count; in pclk_frequency_store()