Lines Matching +full:mbox +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
6 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
10 #include "ivtv-driver.h"
11 #include "ivtv-mailbox.h"
33 const char *name; /* The name of the command */ member
133 u32 flags = readl(&mbdata->mbox[mb].flags); in try_mailbox()
137 if (is_free && !test_and_set_bit(mb, &mbdata->busy)) { in try_mailbox()
138 write_sync(IVTV_MBOX_DRIVER_BUSY, &mbdata->mbox[mb].flags); in try_mailbox()
150 int max_mbox = mbdata->max_mbox; in get_mailbox()
158 /* find free non-DMA mailbox */ in get_mailbox()
172 return -ENODEV; in get_mailbox()
175 static void write_mailbox(volatile struct ivtv_mailbox __iomem *mbox, int cmd, int args, u32 data[]) in write_mailbox() argument
179 write_sync(cmd, &mbox->cmd); in write_mailbox()
180 write_sync(IVTV_API_STD_TIMEOUT, &mbox->timeout); in write_mailbox()
183 write_sync(data[i], &mbox->data[i]); in write_mailbox()
185 write_sync(IVTV_MBOX_DRIVER_DONE | IVTV_MBOX_DRIVER_BUSY, &mbox->flags); in write_mailbox()
192 for (i = 0; i <= mbdata->max_mbox; i++) { in clear_all_mailboxes()
194 i, readl(&mbdata->mbox[i].cmd), readl(&mbdata->mbox[i].flags)); in clear_all_mailboxes()
195 write_sync(0, &mbdata->mbox[i].flags); in clear_all_mailboxes()
196 clear_bit(i, &mbdata->busy); in clear_all_mailboxes()
202 struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox; in ivtv_api_call()
203 volatile struct ivtv_mailbox __iomem *mbox; in ivtv_api_call() local
211 return -ENODEV; in ivtv_api_call()
214 cmd < 0 || cmd > 255 || api_info[cmd].name == NULL) { in ivtv_api_call()
216 return -EINVAL; in ivtv_api_call()
220 IVTV_DEBUG_HI_MB("MB Call: %s\n", api_info[cmd].name); in ivtv_api_call()
223 IVTV_DEBUG_MB("MB Call: %s\n", api_info[cmd].name); in ivtv_api_call()
233 if (itv->api_cache[cmd].last_jiffies && in ivtv_api_call()
235 itv->api_cache[cmd].last_jiffies + in ivtv_api_call()
237 !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { in ivtv_api_call()
238 itv->api_cache[cmd].last_jiffies = jiffies; in ivtv_api_call()
246 mb = i % (mbdata->max_mbox + 1); in ivtv_api_call()
248 write_mailbox(&mbdata->mbox[mb], cmd, args, data); in ivtv_api_call()
249 clear_bit(mb, &mbdata->busy); in ivtv_api_call()
253 api_info[cmd].name, mb, readl(&mbdata->mbox[mb].flags)); in ivtv_api_call()
255 IVTV_WARN("Could not find free DMA mailbox for %s\n", api_info[cmd].name); in ivtv_api_call()
257 return -EBUSY; in ivtv_api_call()
265 IVTV_DEBUG_WARN("No free mailbox found (%s)\n", api_info[cmd].name); in ivtv_api_call()
267 return -EBUSY; in ivtv_api_call()
269 mbox = &mbdata->mbox[mb]; in ivtv_api_call()
270 write_mailbox(mbox, cmd, args, data); in ivtv_api_call()
272 memcpy(itv->api_cache[cmd].data, data, sizeof(itv->api_cache[cmd].data)); in ivtv_api_call()
273 itv->api_cache[cmd].last_jiffies = jiffies; in ivtv_api_call()
276 clear_bit(mb, &mbdata->busy); in ivtv_api_call()
286 if (readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE) in ivtv_api_call()
290 while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) { in ivtv_api_call()
292 IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name); in ivtv_api_call()
294 write_sync(0, &mbox->flags); in ivtv_api_call()
295 clear_bit(mb, &mbdata->busy); in ivtv_api_call()
296 return -EIO; in ivtv_api_call()
305 api_info[cmd].name, in ivtv_api_call()
306 jiffies_to_msecs(jiffies - then)); in ivtv_api_call()
309 data[i] = readl(&mbox->data[i]); in ivtv_api_call()
310 write_sync(0, &mbox->flags); in ivtv_api_call()
311 clear_bit(mb, &mbdata->busy); in ivtv_api_call()
322 return (res == -EBUSY) ? ivtv_api_call(itv, cmd, args, data) : res; in ivtv_api()
361 volatile u32 __iomem *p = mbdata->mbox[mb].data; in ivtv_api_get_data()
372 itv->api_cache[i].last_jiffies = 0; in ivtv_mailbox_cache_invalidate()