drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c- Extension
.c- Size
- 12431 bytes
- Lines
- 491
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/err.hlinux/firmware.hlinux/jiffies.hlinux/sched.hs5p_mfc_cmd.hs5p_mfc_common.hs5p_mfc_debug.hs5p_mfc_intr.hs5p_mfc_opr.hs5p_mfc_pm.hs5p_mfc_ctrl.h
Detected Declarations
function Copyrightfunction s5p_mfc_load_firmwarefunction s5p_mfc_release_firmwarefunction s5p_mfc_bus_resetfunction s5p_mfc_resetfunction s5p_mfc_init_memctrlfunction s5p_mfc_clear_cmdsfunction s5p_mfc_init_hwfunction s5p_mfc_deinit_hwfunction s5p_mfc_sleepfunction s5p_mfc_v8_wait_wakeupfunction s5p_mfc_wait_wakeupfunction s5p_mfc_wakeupfunction s5p_mfc_open_mfc_instfunction s5p_mfc_close_mfc_inst
Annotated Snippet
if (!err) {
dev->fw_ver = (enum s5p_mfc_fw_ver) i;
break;
}
}
if (err != 0) {
mfc_err("Firmware is not present in the /lib/firmware directory nor compiled in kernel\n");
return -EINVAL;
}
if (fw_blob->size > dev->fw_buf.size) {
mfc_err("MFC firmware is too big to be loaded\n");
release_firmware(fw_blob);
return -ENOMEM;
}
memcpy(dev->fw_buf.virt, fw_blob->data, fw_blob->size);
wmb();
dev->fw_get_done = true;
release_firmware(fw_blob);
mfc_debug_leave();
return 0;
}
/* Release firmware memory */
int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev)
{
/* Before calling this function one has to make sure
* that MFC is no longer processing */
s5p_mfc_release_priv_buf(dev, &dev->fw_buf);
dev->fw_get_done = false;
return 0;
}
static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev)
{
unsigned int status;
unsigned long timeout;
/* Reset */
mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL);
timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
/* Check bus status */
do {
if (time_after(jiffies, timeout)) {
mfc_err("Timeout while resetting MFC.\n");
return -EIO;
}
status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL);
} while ((status & 0x2) == 0);
return 0;
}
/* Reset the device */
int s5p_mfc_reset(struct s5p_mfc_dev *dev)
{
unsigned int mc_status;
unsigned long timeout;
int i;
mfc_debug_enter();
if (IS_MFCV6_PLUS(dev)) {
/* Zero Initialization of MFC registers */
mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);
mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6);
for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));
/* check bus reset control before reset */
if (dev->risc_on && !IS_MFCV12(dev))
if (s5p_mfc_bus_reset(dev))
return -EIO;
/* Reset
* set RISC_ON to 0 during power_on & wake_up.
* V6 needs RISC_ON set to 0 during reset also.
*/
if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev)))
mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);
mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);
} else {
/* Stop procedure */
/* reset RISC */
mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET);
/* All reset except for MC */
mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET);
mdelay(10);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/err.h`, `linux/firmware.h`, `linux/jiffies.h`, `linux/sched.h`, `s5p_mfc_cmd.h`, `s5p_mfc_common.h`, `s5p_mfc_debug.h`.
- Detected declarations: `function Copyright`, `function s5p_mfc_load_firmware`, `function s5p_mfc_release_firmware`, `function s5p_mfc_bus_reset`, `function s5p_mfc_reset`, `function s5p_mfc_init_memctrl`, `function s5p_mfc_clear_cmds`, `function s5p_mfc_init_hw`, `function s5p_mfc_deinit_hw`, `function s5p_mfc_sleep`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.