drivers/media/pci/saa7164/saa7164-cmd.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/saa7164/saa7164-cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/saa7164/saa7164-cmd.c- Extension
.c- Size
- 13470 bytes
- Lines
- 541
- 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/wait.hsaa7164.h
Detected Declarations
function Copyrightfunction saa7164_cmd_free_seqnofunction saa7164_cmd_timeout_seqnofunction saa7164_cmd_timeout_getfunction saa7164_irq_dequeuefunction saa7164_cmd_dequeuefunction saa7164_cmd_setfunction saa7164_cmd_waitfunction saa7164_cmd_send
Annotated Snippet
if (dev->cmds[i].inuse == 0) {
dev->cmds[i].inuse = 1;
dev->cmds[i].signalled = 0;
dev->cmds[i].timeout = 0;
ret = dev->cmds[i].seqno;
break;
}
}
mutex_unlock(&dev->lock);
return ret;
}
static void saa7164_cmd_free_seqno(struct saa7164_dev *dev, u8 seqno)
{
mutex_lock(&dev->lock);
if ((dev->cmds[seqno].inuse == 1) &&
(dev->cmds[seqno].seqno == seqno)) {
dev->cmds[seqno].inuse = 0;
dev->cmds[seqno].signalled = 0;
dev->cmds[seqno].timeout = 0;
}
mutex_unlock(&dev->lock);
}
static void saa7164_cmd_timeout_seqno(struct saa7164_dev *dev, u8 seqno)
{
mutex_lock(&dev->lock);
if ((dev->cmds[seqno].inuse == 1) &&
(dev->cmds[seqno].seqno == seqno)) {
dev->cmds[seqno].timeout = 1;
}
mutex_unlock(&dev->lock);
}
static u32 saa7164_cmd_timeout_get(struct saa7164_dev *dev, u8 seqno)
{
int ret = 0;
mutex_lock(&dev->lock);
if ((dev->cmds[seqno].inuse == 1) &&
(dev->cmds[seqno].seqno == seqno)) {
ret = dev->cmds[seqno].timeout;
}
mutex_unlock(&dev->lock);
return ret;
}
/* Commands to the f/w get marshelled to/from this code then onto the PCI
* -bus/c running buffer. */
int saa7164_irq_dequeue(struct saa7164_dev *dev)
{
int ret = SAA_OK, i = 0;
u32 timeout;
wait_queue_head_t *q = NULL;
u8 tmp[512];
dprintk(DBGLVL_CMD, "%s()\n", __func__);
/* While any outstand message on the bus exists... */
do {
/* Peek the msg bus */
struct tmComResInfo tRsp = { 0, 0, 0, 0, 0, 0 };
ret = saa7164_bus_get(dev, &tRsp, NULL, 1);
if (ret != SAA_OK)
break;
q = &dev->cmds[tRsp.seqno].wait;
timeout = saa7164_cmd_timeout_get(dev, tRsp.seqno);
dprintk(DBGLVL_CMD, "%s() timeout = %d\n", __func__, timeout);
if (!timeout) {
dprintk(DBGLVL_CMD,
"%s() signalled seqno(%d) (for dequeue)\n",
__func__, tRsp.seqno);
dev->cmds[tRsp.seqno].signalled = 1;
wake_up(q);
} else {
printk(KERN_ERR
"%s() found timed out command on the bus\n",
__func__);
/* Clean the bus */
ret = saa7164_bus_get(dev, &tRsp, &tmp, 0);
printk(KERN_ERR "%s() ret = %x\n", __func__, ret);
if (ret == SAA_ERR_EMPTY)
/* Someone else already fetched the response */
return SAA_OK;
if (ret != SAA_OK)
Annotation
- Immediate include surface: `linux/wait.h`, `saa7164.h`.
- Detected declarations: `function Copyright`, `function saa7164_cmd_free_seqno`, `function saa7164_cmd_timeout_seqno`, `function saa7164_cmd_timeout_get`, `function saa7164_irq_dequeue`, `function saa7164_cmd_dequeue`, `function saa7164_cmd_set`, `function saa7164_cmd_wait`, `function saa7164_cmd_send`.
- 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.