drivers/media/pci/mgb4/mgb4_sysfs_out.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/mgb4/mgb4_sysfs_out.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/mgb4/mgb4_sysfs_out.c- Extension
.c- Size
- 21594 bytes
- Lines
- 826
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/nospec.hmgb4_core.hmgb4_i2c.hmgb4_vout.hmgb4_vin.hmgb4_cmt.hmgb4_sysfs.h
Detected Declarations
function Copyrightfunction is_busyfunction output_id_showfunction video_source_showfunction globalfunction color_mapping_showfunction color_mapping_storefunction display_width_showfunction display_width_storefunction display_height_showfunction display_height_storefunction frame_rate_showfunction frame_rate_storefunction hsync_width_showfunction hsync_width_storefunction vsync_width_showfunction vsync_width_storefunction hback_porch_showfunction hback_porch_storefunction vback_porch_showfunction vback_porch_storefunction hfront_porch_showfunction hfront_porch_storefunction vfront_porch_showfunction vfront_porch_storefunction hsync_polarity_showfunction hsync_polarity_storefunction vsync_polarity_showfunction vsync_polarity_storefunction de_polarity_showfunction de_polarity_storefunction fpdl3_output_width_showfunction fpdl3_output_width_storefunction pclk_frequency_showfunction pclk_frequency_store
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021-2023 Digiteq Automotive
* author: Martin Tuma <martin.tuma@digiteqautomotive.com>
*
* This module handles all the sysfs info/configuration that is related to the
* v4l2 output devices.
*/
#include <linux/device.h>
#include <linux/nospec.h>
#include "mgb4_core.h"
#include "mgb4_i2c.h"
#include "mgb4_vout.h"
#include "mgb4_vin.h"
#include "mgb4_cmt.h"
#include "mgb4_sysfs.h"
static int loopin_cnt(struct mgb4_vin_dev *vindev)
{
struct mgb4_vout_dev *voutdev;
u32 config;
int i, cnt = 0;
for (i = 0; i < MGB4_VOUT_DEVICES; i++) {
voutdev = vindev->mgbdev->vout[i];
if (!voutdev)
continue;
config = mgb4_read_reg(&voutdev->mgbdev->video,
voutdev->config->regs.config);
if ((config & 0xc) >> 2 == vindev->config->id)
cnt++;
}
return cnt;
}
static bool is_busy(struct video_device *dev)
{
bool ret;
mutex_lock(dev->lock);
ret = vb2_is_busy(dev->queue);
mutex_unlock(dev->lock);
return ret;
}
/* Common for both FPDL3 and GMSL */
static ssize_t output_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct video_device *vdev = to_video_device(dev);
struct mgb4_vout_dev *voutdev = video_get_drvdata(vdev);
return sprintf(buf, "%d\n", voutdev->config->id);
}
static ssize_t video_source_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct video_device *vdev = to_video_device(dev);
struct mgb4_vout_dev *voutdev = video_get_drvdata(vdev);
u32 config = mgb4_read_reg(&voutdev->mgbdev->video,
voutdev->config->regs.config);
return sprintf(buf, "%u\n", (config & 0xc) >> 2);
}
/*
* Video source change may affect the buffer queue of ANY video input/output on
* the card thus if any of the inputs/outputs is in use, we do not allow
* the change.
*
* As we do not want to lock all the video devices at the same time, a two-stage
* locking strategy is used. In addition to the video device locking there is
* a global (PCI device) variable "io_reconfig" atomically checked/set when
* the reconfiguration is running. All the video devices check the variable in
* their queue_setup() functions and do not allow to start the queue when
* the reconfiguration has started.
*/
static ssize_t video_source_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct video_device *vdev = to_video_device(dev);
struct mgb4_vout_dev *voutdev = video_get_drvdata(vdev);
struct mgb4_dev *mgbdev = voutdev->mgbdev;
Annotation
- Immediate include surface: `linux/device.h`, `linux/nospec.h`, `mgb4_core.h`, `mgb4_i2c.h`, `mgb4_vout.h`, `mgb4_vin.h`, `mgb4_cmt.h`, `mgb4_sysfs.h`.
- Detected declarations: `function Copyright`, `function is_busy`, `function output_id_show`, `function video_source_show`, `function global`, `function color_mapping_show`, `function color_mapping_store`, `function display_width_show`, `function display_width_store`, `function display_height_show`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.