21 #include <linux/slab.h>
25 static struct class *crystalhd_class;
43 if (!adp || !adp->
pdev) {
48 if (adp->
pdev->msi_enabled)
51 adp->
msi = pci_enable_msi(adp->
pdev);
54 adp->
name, (
void *)adp);
65 if (!adp || !adp->
pdev) {
80 unsigned long flags = 0;
91 memset(temp, 0,
sizeof(*temp));
94 spin_unlock_irqrestore(&adp->
lock, flags);
101 unsigned long flags = 0;
109 spin_unlock_irqrestore(&adp->
lock, flags);
112 static inline int crystalhd_user_data(
unsigned long ud,
void *dr,
int size,
int set)
137 unsigned long ua_off;
140 if (!adp || !io || !ua || !m_sz) {
152 ua_off = ua +
sizeof(io->
udata);
155 BCMLOG_ERR(
"failed to pull add_cdata sz:%x ua_off:%x\n",
168 unsigned long ua_off;
171 if (!adp || !io || !ua) {
177 ua_off = ua +
sizeof(io->
udata);
178 rc = crystalhd_user_data(ua_off, io->
add_cdata,
181 BCMLOG_ERR(
"failed to push add_cdata sz:%x ua_off:%x\n",
197 unsigned long ua,
int set)
202 if (!adp || !io || !ua) {
207 rc = crystalhd_user_data(ua, &io->
udata,
sizeof(io->
udata),
set);
209 BCMLOG_ERR(
"failed to %s iodata\n", (
set ?
"set" :
"get"));
217 m_sz = io->
udata.u.devMem.NumDwords * 4;
219 rc = chd_dec_release_cdata(adp, io, ua);
221 rc = chd_dec_fetch_cdata(adp, io, m_sz, ua);
230 static int chd_dec_api_cmd(
struct crystalhd_adp *adp,
unsigned long ua,
246 rc = chd_dec_proc_user_data(adp, temp, ua, 0);
252 rc = chd_dec_proc_user_data(adp, temp, ua, 1);
264 static long chd_dec_ioctl(
struct file *
fd,
unsigned int cmd,
unsigned long ua)
290 ret = chd_dec_api_cmd(adp, ua, uc->
uid, cmd, cproc);
295 static int chd_dec_open(
struct inode *
in,
struct file *fd)
325 static int chd_dec_close(
struct inode *in,
struct file *fd)
350 .unlocked_ioctl = chd_dec_ioctl,
351 .open = chd_dec_open,
352 .release = chd_dec_close,
375 if (IS_ERR(crystalhd_class)) {
376 rc = PTR_ERR(crystalhd_class);
378 goto class_create_fail;
386 goto device_create_fail;
399 BCMLOG_ERR(
"ioctl data pool kzalloc failed\n");
455 bar2, mem_len, bar0, i2o_len);
465 BCMLOG_ERR(
"Failed to remap mem region...\n");
480 BCMLOG_ERR(
"Failed to remap mem region...\n");
489 BCMLOG_ERR(
"Region request failed: %d\n", rc);
494 (
unsigned long)pinfo->
addr, (
unsigned long)pinfo->
i2o_addr);
519 pinfo = pci_get_drvdata(pdev);
529 chd_dec_release_chdev(pinfo);
531 chd_dec_disable_int(pinfo);
533 chd_pci_release_mem(pinfo);
548 "s_vendor:0x%04x s_device: 0x%04x\n",
570 rc = chd_pci_reserve_mem(pinfo);
572 BCMLOG_ERR(
"Failed to setup memory regions.\n");
585 chd_dec_init_chdev(pinfo);
586 rc = chd_dec_enable_int(pinfo);
618 pci_set_drvdata(pdev, pinfo);
636 adp = pci_get_drvdata(pdev);
655 chd_dec_disable_int(adp);
664 int chd_dec_pci_resume(
struct pci_dev *pdev)
670 adp = pci_get_drvdata(pdev);
687 rc = chd_dec_enable_int(adp);
711 static struct pci_driver bc_chd_70012_driver = {
712 .name =
"Broadcom 70012 Decoder",
713 .probe = chd_dec_pci_probe,
715 .id_table = chd_dec_pci_id_table,
717 .suspend = chd_dec_pci_suspend,
718 .resume = chd_dec_pci_resume
724 if ((!arg) || (
strlen(arg) < 3))
726 else if (!
strncmp(arg,
"sstep", 5))
729 else if (!
strncmp(arg,
"info", 4))
731 else if (!
strncmp(arg,
"debug", 5))
734 else if (!
strncmp(arg,
"pball", 5))
736 else if (!
strncmp(arg,
"silent", 6))
747 static int __init chd_dec_module_init(
void)
755 rc = pci_register_driver(&bc_chd_70012_driver);
758 BCMLOG_ERR(
"Could not find any devices. err:%d\n", rc);
764 static void __exit chd_dec_module_cleanup(
void)