Lines Matching refs:dev
12 static int saa7164_cmd_alloc_seqno(struct saa7164_dev *dev) in saa7164_cmd_alloc_seqno() argument
16 mutex_lock(&dev->lock); in saa7164_cmd_alloc_seqno()
18 if (dev->cmds[i].inuse == 0) { in saa7164_cmd_alloc_seqno()
19 dev->cmds[i].inuse = 1; in saa7164_cmd_alloc_seqno()
20 dev->cmds[i].signalled = 0; in saa7164_cmd_alloc_seqno()
21 dev->cmds[i].timeout = 0; in saa7164_cmd_alloc_seqno()
22 ret = dev->cmds[i].seqno; in saa7164_cmd_alloc_seqno()
26 mutex_unlock(&dev->lock); in saa7164_cmd_alloc_seqno()
31 static void saa7164_cmd_free_seqno(struct saa7164_dev *dev, u8 seqno) in saa7164_cmd_free_seqno() argument
33 mutex_lock(&dev->lock); in saa7164_cmd_free_seqno()
34 if ((dev->cmds[seqno].inuse == 1) && in saa7164_cmd_free_seqno()
35 (dev->cmds[seqno].seqno == seqno)) { in saa7164_cmd_free_seqno()
36 dev->cmds[seqno].inuse = 0; in saa7164_cmd_free_seqno()
37 dev->cmds[seqno].signalled = 0; in saa7164_cmd_free_seqno()
38 dev->cmds[seqno].timeout = 0; in saa7164_cmd_free_seqno()
40 mutex_unlock(&dev->lock); in saa7164_cmd_free_seqno()
43 static void saa7164_cmd_timeout_seqno(struct saa7164_dev *dev, u8 seqno) in saa7164_cmd_timeout_seqno() argument
45 mutex_lock(&dev->lock); in saa7164_cmd_timeout_seqno()
46 if ((dev->cmds[seqno].inuse == 1) && in saa7164_cmd_timeout_seqno()
47 (dev->cmds[seqno].seqno == seqno)) { in saa7164_cmd_timeout_seqno()
48 dev->cmds[seqno].timeout = 1; in saa7164_cmd_timeout_seqno()
50 mutex_unlock(&dev->lock); in saa7164_cmd_timeout_seqno()
53 static u32 saa7164_cmd_timeout_get(struct saa7164_dev *dev, u8 seqno) in saa7164_cmd_timeout_get() argument
57 mutex_lock(&dev->lock); in saa7164_cmd_timeout_get()
58 if ((dev->cmds[seqno].inuse == 1) && in saa7164_cmd_timeout_get()
59 (dev->cmds[seqno].seqno == seqno)) { in saa7164_cmd_timeout_get()
60 ret = dev->cmds[seqno].timeout; in saa7164_cmd_timeout_get()
62 mutex_unlock(&dev->lock); in saa7164_cmd_timeout_get()
69 int saa7164_irq_dequeue(struct saa7164_dev *dev) in saa7164_irq_dequeue() argument
82 ret = saa7164_bus_get(dev, &tRsp, NULL, 1); in saa7164_irq_dequeue()
86 q = &dev->cmds[tRsp.seqno].wait; in saa7164_irq_dequeue()
87 timeout = saa7164_cmd_timeout_get(dev, tRsp.seqno); in saa7164_irq_dequeue()
93 dev->cmds[tRsp.seqno].signalled = 1; in saa7164_irq_dequeue()
101 ret = saa7164_bus_get(dev, &tRsp, &tmp, 0); in saa7164_irq_dequeue()
121 static int saa7164_cmd_dequeue(struct saa7164_dev *dev) in saa7164_cmd_dequeue() argument
132 ret = saa7164_bus_get(dev, &tRsp, NULL, 1); in saa7164_cmd_dequeue()
139 q = &dev->cmds[tRsp.seqno].wait; in saa7164_cmd_dequeue()
140 timeout = saa7164_cmd_timeout_get(dev, tRsp.seqno); in saa7164_cmd_dequeue()
146 ret = saa7164_bus_get(dev, &tRsp, &tmp, 0); in saa7164_cmd_dequeue()
158 saa7164_cmd_free_seqno(dev, tRsp.seqno); in saa7164_cmd_dequeue()
166 dev->cmds[tRsp.seqno].signalled = 1; in saa7164_cmd_dequeue()
172 static int saa7164_cmd_set(struct saa7164_dev *dev, struct tmComResInfo *msg, in saa7164_cmd_set() argument
175 struct tmComResBusInfo *bus = &dev->bus; in saa7164_cmd_set()
187 mutex_lock(&dev->cmds[msg->id].lock); in saa7164_cmd_set()
203 ret = saa7164_bus_set(dev, msg, tmp); in saa7164_cmd_set()
223 ret = saa7164_bus_set(dev, msg, buf + idx * bus->m_wMaxReqSize); in saa7164_cmd_set()
237 mutex_unlock(&dev->cmds[msg->id].lock); in saa7164_cmd_set()
244 static int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno) in saa7164_cmd_wait() argument
252 saa7164_bus_dump(dev); in saa7164_cmd_wait()
256 mutex_lock(&dev->lock); in saa7164_cmd_wait()
257 if ((dev->cmds[seqno].inuse == 1) && in saa7164_cmd_wait()
258 (dev->cmds[seqno].seqno == seqno)) { in saa7164_cmd_wait()
259 q = &dev->cmds[seqno].wait; in saa7164_cmd_wait()
261 mutex_unlock(&dev->lock); in saa7164_cmd_wait()
265 if (dev->cmds[seqno].signalled == 0) { in saa7164_cmd_wait()
269 __func__, seqno, dev->cmds[seqno].signalled); in saa7164_cmd_wait()
278 wait_event_timeout(*q, dev->cmds[seqno].signalled, in saa7164_cmd_wait()
284 saa7164_cmd_timeout_seqno(dev, seqno); in saa7164_cmd_wait()
288 dev->cmds[seqno].signalled); in saa7164_cmd_wait()
298 void saa7164_cmd_signal(struct saa7164_dev *dev, u8 seqno) in saa7164_cmd_signal() argument
303 mutex_lock(&dev->lock); in saa7164_cmd_signal()
305 if (dev->cmds[i].inuse == 1) { in saa7164_cmd_signal()
308 dev->cmds[i].seqno, in saa7164_cmd_signal()
309 dev->cmds[i].signalled, in saa7164_cmd_signal()
310 dev->cmds[i].timeout); in saa7164_cmd_signal()
315 if ((dev->cmds[i].inuse == 1) && ((i == 0) || in saa7164_cmd_signal()
316 (dev->cmds[i].signalled) || (dev->cmds[i].timeout))) { in saa7164_cmd_signal()
319 dev->cmds[i].signalled = 1; in saa7164_cmd_signal()
320 wake_up(&dev->cmds[i].wait); in saa7164_cmd_signal()
323 mutex_unlock(&dev->lock); in saa7164_cmd_signal()
326 int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command, in saa7164_cmd_send() argument
339 __func__, saa7164_unitid_name(dev, id), id, in saa7164_cmd_send()
358 ret = saa7164_cmd_alloc_seqno(dev); in saa7164_cmd_send()
377 ret = saa7164_cmd_set(dev, pcommand_t, buf); in saa7164_cmd_send()
382 saa7164_cmd_free_seqno(dev, pcommand_t->seqno); in saa7164_cmd_send()
386 saa7164_cmd_timeout_seqno(dev, pcommand_t->seqno); in saa7164_cmd_send()
397 ret = saa7164_cmd_wait(dev, pcommand_t->seqno); in saa7164_cmd_send()
404 saa7164_cmd_timeout_seqno(dev, pcommand_t->seqno); in saa7164_cmd_send()
414 ret = saa7164_bus_get(dev, presponse_t, NULL, 1); in saa7164_cmd_send()
440 ret = saa7164_cmd_dequeue(dev); in saa7164_cmd_send()
458 ret = saa7164_bus_get(dev, presponse_t, &errdata[0], 0); in saa7164_cmd_send()
464 saa7164_cmd_free_seqno(dev, pcommand_t->seqno); in saa7164_cmd_send()
506 if (saa7164_cmd_dequeue(dev) != SAA_OK) in saa7164_cmd_send()
523 ret = saa7164_bus_get(dev, presponse_t, NULL, 0); in saa7164_cmd_send()
530 if (saa7164_cmd_dequeue(dev) != SAA_OK) in saa7164_cmd_send()
536 ret = saa7164_bus_get(dev, presponse_t, buf + data_recd, 0); in saa7164_cmd_send()
549 if (saa7164_cmd_dequeue(dev) != SAA_OK) in saa7164_cmd_send()
554 saa7164_cmd_free_seqno(dev, pcommand_t->seqno); in saa7164_cmd_send()
561 if (saa7164_cmd_dequeue(dev) != SAA_OK) in saa7164_cmd_send()