Lines Matching full:bt

51 #define btwrite(dat,adr)    bmtwrite((dat), (bt->bt878_mem+(adr)))
52 #define btread(adr) bmtread(bt->bt878_mem+(adr))
67 static void bt878_mem_free(struct bt878 *bt) in bt878_mem_free() argument
69 if (bt->buf_cpu) { in bt878_mem_free()
70 dma_free_coherent(&bt->dev->dev, bt->buf_size, bt->buf_cpu, in bt878_mem_free()
71 bt->buf_dma); in bt878_mem_free()
72 bt->buf_cpu = NULL; in bt878_mem_free()
75 if (bt->risc_cpu) { in bt878_mem_free()
76 dma_free_coherent(&bt->dev->dev, bt->risc_size, bt->risc_cpu, in bt878_mem_free()
77 bt->risc_dma); in bt878_mem_free()
78 bt->risc_cpu = NULL; in bt878_mem_free()
82 static int bt878_mem_alloc(struct bt878 *bt) in bt878_mem_alloc() argument
84 if (!bt->buf_cpu) { in bt878_mem_alloc()
85 bt->buf_size = 128 * 1024; in bt878_mem_alloc()
87 bt->buf_cpu = dma_alloc_coherent(&bt->dev->dev, bt->buf_size, in bt878_mem_alloc()
88 &bt->buf_dma, GFP_KERNEL); in bt878_mem_alloc()
89 if (!bt->buf_cpu) in bt878_mem_alloc()
93 if (!bt->risc_cpu) { in bt878_mem_alloc()
94 bt->risc_size = PAGE_SIZE; in bt878_mem_alloc()
95 bt->risc_cpu = dma_alloc_coherent(&bt->dev->dev, bt->risc_size, in bt878_mem_alloc()
96 &bt->risc_dma, GFP_KERNEL); in bt878_mem_alloc()
97 if (!bt->risc_cpu) { in bt878_mem_alloc()
98 bt878_mem_free(bt); in bt878_mem_alloc()
120 #define RISC_FLUSH() bt->risc_pos = 0
121 #define RISC_INSTR(instr) bt->risc_cpu[bt->risc_pos++] = cpu_to_le32(instr)
123 static int bt878_make_risc(struct bt878 *bt) in bt878_make_risc() argument
125 bt->block_bytes = bt->buf_size >> 4; in bt878_make_risc()
126 bt->block_count = 1 << 4; in bt878_make_risc()
127 bt->line_bytes = bt->block_bytes; in bt878_make_risc()
128 bt->line_count = bt->block_count; in bt878_make_risc()
130 while (bt->line_bytes > 4095) { in bt878_make_risc()
131 bt->line_bytes >>= 1; in bt878_make_risc()
132 bt->line_count <<= 1; in bt878_make_risc()
135 if (bt->line_count > 255) { in bt878_make_risc()
143 static void bt878_risc_program(struct bt878 *bt, u32 op_sync_orin) in bt878_risc_program() argument
153 bt->line_count, bt->line_bytes); in bt878_risc_program()
154 for (line = 0; line < bt->line_count; line++) { in bt878_risc_program()
156 if (!(buf_pos % bt->block_bytes)) in bt878_risc_program()
160 bt->block_bytes) + in bt878_risc_program()
161 (bt->block_count - in bt878_risc_program()
163 bt->block_count) | bt-> in bt878_risc_program()
167 bt->line_bytes); in bt878_risc_program()
168 RISC_INSTR(bt->buf_dma + buf_pos); in bt878_risc_program()
169 buf_pos += bt->line_bytes; in bt878_risc_program()
176 RISC_INSTR(bt->risc_dma); in bt878_risc_program()
178 btwrite((bt->line_count << 16) | bt->line_bytes, BT878_APACK_LEN); in bt878_risc_program()
185 void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin, in bt878_start() argument
194 bt878_risc_program(bt, op_sync_orin); in bt878_start()
198 btwrite(bt->risc_dma, BT878_ARISC_START); in bt878_start()
219 void bt878_stop(struct bt878 *bt) in bt878_stop() argument
237 bt->nr, i, stat); in bt878_stop()
251 struct bt878 *bt; in bt878_irq() local
253 bt = (struct bt878 *) dev_id; in bt878_irq()
261 /* dprintk("bt878(%d) debug: irq count %d, stat 0x%8.8x, mask 0x%8.8x\n",bt->nr,count,stat,mask); … in bt878_irq()
269 bt->nr, in bt878_irq()
280 bt->nr, in bt878_irq()
293 bt->nr, in bt878_irq()
302 bt->finished_block = (stat & BT878_ARISCS) >> 28; in bt878_irq()
303 if (bt->bh_work.func) in bt878_irq()
304 queue_work(system_bh_wq, &bt->bh_work); in bt878_irq()
312 bt->nr); in bt878_irq()
320 bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp) in bt878_device_control() argument
325 if (mutex_lock_interruptible(&bt->gpio_lock)) in bt878_device_control()
331 retval = bttv_gpio_enable(bt->bttv_nr, in bt878_device_control()
337 retval = bttv_write_gpio(bt->bttv_nr, in bt878_device_control()
344 retval = bttv_read_gpio(bt->bttv_nr, &mp->rd.value); in bt878_device_control()
349 bt->TS_Size = mp->psize; in bt878_device_control()
356 mutex_unlock(&bt->gpio_lock); in bt878_device_control()
402 struct bt878 *bt; in bt878_probe() local
420 bt = &bt878[bt878_num]; in bt878_probe()
421 bt->dev = dev; in bt878_probe()
422 bt->nr = bt878_num; in bt878_probe()
423 bt->shutdown = 0; in bt878_probe()
425 bt->id = dev->device; in bt878_probe()
426 bt->irq = dev->irq; in bt878_probe()
427 bt->bt878_adr = pci_resource_start(dev, 0); in bt878_probe()
434 bt->revision = dev->revision; in bt878_probe()
438 printk(KERN_INFO "bt878(%d): Bt%x (rev %d) at %02x:%02x.%x, ", in bt878_probe()
439 bt878_num, bt->id, bt->revision, dev->bus->number, in bt878_probe()
442 bt->irq, lat, bt->bt878_adr); in bt878_probe()
445 bt->bt878_mem = (unsigned char *) bt->bt878_adr; in bt878_probe()
447 bt->bt878_mem = ioremap(bt->bt878_adr, 0x1000); in bt878_probe()
453 result = request_irq(bt->irq, bt878_irq, in bt878_probe()
454 IRQF_SHARED, "bt878", (void *) bt); in bt878_probe()
463 bt878_num, bt->irq); in bt878_probe()
470 pci_set_drvdata(dev, bt); in bt878_probe()
472 if ((result = bt878_mem_alloc(bt))) { in bt878_probe()
477 bt878_make_risc(bt); in bt878_probe()
481 if (!bt->bh_work.func) in bt878_probe()
482 disable_work_sync(&bt->bh_work); in bt878_probe()
487 free_irq(bt->irq, bt); in bt878_probe()
489 release_mem_region(pci_resource_start(bt->dev, 0), in bt878_probe()
490 pci_resource_len(bt->dev, 0)); in bt878_probe()
499 struct bt878 *bt = pci_get_drvdata(pci_dev); in bt878_remove() local
502 printk(KERN_INFO "bt878(%d): unloading\n", bt->nr); in bt878_remove()
512 pci_read_config_byte(bt->dev, PCI_COMMAND, &command); in bt878_remove()
515 pci_write_config_byte(bt->dev, PCI_COMMAND, command); in bt878_remove()
517 free_irq(bt->irq, bt); in bt878_remove()
518 printk(KERN_DEBUG "bt878_mem: 0x%p.\n", bt->bt878_mem); in bt878_remove()
519 if (bt->bt878_mem) in bt878_remove()
520 iounmap(bt->bt878_mem); in bt878_remove()
522 release_mem_region(pci_resource_start(bt->dev, 0), in bt878_remove()
523 pci_resource_len(bt->dev, 0)); in bt878_remove()
528 bt->shutdown = 1; in bt878_remove()
529 bt878_mem_free(bt); in bt878_remove()