23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29 #include <linux/errno.h>
30 #include <linux/kernel.h>
32 #include <linux/module.h>
35 #include <linux/fcntl.h>
37 #include <linux/slab.h>
49 unsigned int bpl,
u32 risc)
51 unsigned int i, lines;
72 for (i = 0; i < lines; i++) {
90 for (i = 24; i < 80; i += 4)
123 if (fifo_enable && line == 2) {
127 *(rp++) = 0x00000020;
138 unsigned int bpl,
unsigned int lines)
144 int databuf_offset = 0;
155 databuf_offset = frame_size *
frame;
167 risc_phys_jump_addr =
171 risc_phys_jump_addr =
177 rp = cx25821_risc_field_upstream_audio(dev, rp,
224 pr_fmt(
"No audio file is currently running so return!\n"));
269 char mybuf[line_size];
279 if (IS_ERR(myfile)) {
280 const int open_errno = -PTR_ERR(myfile);
281 pr_err(
"%s(): ERROR opening file(%s) with errno = %d!\n",
283 return PTR_ERR(myfile);
285 if (!(myfile->
f_op)) {
286 pr_err(
"%s(): File has no file operations registered!\n",
292 if (!myfile->
f_op->read) {
293 pr_err(
"%s(): File has no READ operations registered!\n",
306 vfs_read_retval =
vfs_read(myfile, mybuf, line_size,
309 if (vfs_read_retval > 0 && vfs_read_retval == line_size
312 frame_offset / 4), mybuf,
316 file_offset += vfs_read_retval;
317 frame_offset += vfs_read_retval;
319 if (vfs_read_retval < line_size) {
320 pr_info(
"Done: exit %s() since no more bytes to read from Audio file\n",
345 pr_err(
"ERROR %s(): since container_of(work_struct) FAILED!\n",
361 char mybuf[line_size];
363 loff_t offset = (
unsigned long)0;
368 if (IS_ERR(myfile)) {
369 const int open_errno = -PTR_ERR(myfile);
370 pr_err(
"%s(): ERROR opening file(%s) with errno = %d!\n",
372 return PTR_ERR(myfile);
374 if (!(myfile->
f_op)) {
375 pr_err(
"%s(): File has no file operations registered!\n",
381 if (!myfile->
f_op->read) {
382 pr_err(
"%s(): File has no READ operations registered!\n",
396 vfs_read_retval =
vfs_read(myfile, mybuf,
399 if (vfs_read_retval > 0 &&
400 vfs_read_retval == line_size &&
403 _audiodata_buf_virt_addr
404 + offset / 4), mybuf,
408 offset += vfs_read_retval;
410 if (vfs_read_retval < line_size) {
411 pr_info(
"Done: exit %s() since no more bytes to read from Audio file\n",
420 if (vfs_read_retval < line_size)
435 static int cx25821_audio_upstream_buffer_prepare(
struct cx25821_dev *dev,
454 pr_fmt(
"ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning\n"));
468 pr_fmt(
"ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning\n"));
483 pr_fmt(
"ERROR creating audio upstream RISC programs!\n"));
511 spin_lock(&dev->
slock);
530 risc_phys_jump_addr =
535 rp = cx25821_risc_field_upstream_audio(dev,
554 spin_unlock(&dev->
slock);
557 pr_warn(
"%s(): Audio Received Overflow Error Interrupt!\n",
561 pr_warn(
"%s(): Audio Received Sync Error Interrupt!\n",
565 pr_warn(
"%s(): Audio Received OpCode Error Interrupt!\n",
574 pr_warn(
"EOF Channel Audio Framecount = %d\n",
613 static void cx25821_wait_fifo_enable(
struct cx25821_dev *dev,
627 if (count++ > 1000) {
628 pr_err(
"ERROR: %s() fifo is NOT turned on. Timeout!\n",
678 pr_err(
"%s: can't get upstream IRQ %d\n", dev->
name,
691 cx25821_wait_fifo_enable(dev, sram_ch);
708 pr_warn(
"Audio Channel is still running so return!\n");
713 sram_ch = dev->
channels[channel_select].sram_channels;
722 pr_fmt(
"ERROR: create_singlethread_workqueue() for Audio FAILED!\n"));
762 retval = cx25821_audio_upstream_buffer_prepare(dev, sram_ch,
765 pr_err(
"%s: Failed to set up Audio upstream buffers!\n",