1 // SPDX-License-Identifier: GPL-2.0-or-later
6 bt848/bt878/cx2388x risc code generator.
8 (c) 2000-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/pci.h>
18 #include <linux/interrupt.h>
19 #include <linux/videodev2.h>
20 #include <linux/pgtable.h>
23 #include "btcx-risc.h"
25 static unsigned int btcx_debug
;
26 module_param(btcx_debug
, int, 0644);
27 MODULE_PARM_DESC(btcx_debug
,"debug messages, default is 0 (no)");
29 #define dprintk(fmt, arg...) do { \
31 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
36 /* ---------------------------------------------------------- */
37 /* allocate/free risc memory */
41 void btcx_riscmem_free(struct pci_dev
*pci
,
42 struct btcx_riscmem
*risc
)
44 if (NULL
== risc
->cpu
)
48 dprintk("btcx: riscmem free [%d] dma=%lx\n",
49 memcnt
, (unsigned long)risc
->dma
);
51 dma_free_coherent(&pci
->dev
, risc
->size
, risc
->cpu
, risc
->dma
);
52 memset(risc
,0,sizeof(*risc
));
55 int btcx_riscmem_alloc(struct pci_dev
*pci
,
56 struct btcx_riscmem
*risc
,
62 if (NULL
!= risc
->cpu
&& risc
->size
< size
)
63 btcx_riscmem_free(pci
,risc
);
64 if (NULL
== risc
->cpu
) {
65 cpu
= dma_alloc_coherent(&pci
->dev
, size
, &dma
, GFP_KERNEL
);
73 dprintk("btcx: riscmem alloc [%d] dma=%lx cpu=%p size=%d\n",
74 memcnt
, (unsigned long)dma
, cpu
, size
);