int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) { struct sram_channel *sram_ch; int err = 0; if (dev->_audio_is_running) { pr_warn("Audio Channel is still running so return!\n"); return 0; } dev->_audio_upstream_channel = channel_select; sram_ch = dev->channels[channel_select].sram_channels; /* Work queue */ INIT_WORK(&dev->_audio_work_entry, cx25821_audioups_handler); dev->_irq_audio_queues = create_singlethread_workqueue("cx25821_audioworkqueue"); if (!dev->_irq_audio_queues) { printk(KERN_DEBUG pr_fmt("ERROR: create_singlethread_workqueue() for Audio FAILED!\n")); return -ENOMEM; } dev->_last_index_irq = 0; dev->_audio_is_running = 0; dev->_audioframe_count = 0; dev->_audiofile_status = RESET_STATUS; dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; _line_size = AUDIO_LINE_SIZE; if (dev->input_audiofilename) { dev->_audiofilename = kstrdup(dev->input_audiofilename, GFP_KERNEL); if (!dev->_audiofilename) { err = -ENOMEM; goto error; } /* Default if filename is empty string */ if (strcmp(dev->input_audiofilename, "") == 0) dev->_audiofilename = "/root/audioGOOD.wav"; } else { dev->_audiofilename = kstrdup(_defaultAudioName, GFP_KERNEL); if (!dev->_audiofilename) { err = -ENOMEM; goto error; } } cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, _line_size, 0); dev->audio_upstream_riscbuf_size = AUDIO_RISC_DMA_BUF_SIZE * NUM_AUDIO_PROGS + RISC_SYNC_INSTRUCTION_SIZE; dev->audio_upstream_databuf_size = AUDIO_DATA_BUF_SZ * NUM_AUDIO_PROGS; /* Allocating buffers and prepare RISC program */ err = cx25821_audio_upstream_buffer_prepare(dev, sram_ch, _line_size); if (err < 0) { pr_err("%s: Failed to set up Audio upstream buffers!\n", dev->name); goto error; } /* Start RISC engine */ cx25821_start_audio_dma_upstream(dev, sram_ch); return 0; error: cx25821_dev_unregister(dev); return err; }
int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) { struct sram_channel *sram_ch; int retval = 0; int err = 0; int str_length = 0; if (dev->_audio_is_running) { printk("Audio Channel is still running so return!\n"); return 0; } dev->_audio_upstream_channel_select = channel_select; sram_ch = &dev->sram_channels[channel_select]; //Work queue INIT_WORK(&dev->_audio_work_entry, cx25821_audioups_handler); dev->_irq_audio_queues = create_singlethread_workqueue("cx25821_audioworkqueue"); if (!dev->_irq_audio_queues) { printk ("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n"); return -ENOMEM; } dev->_last_index_irq = 0; dev->_audio_is_running = 0; dev->_audioframe_count = 0; dev->_audiofile_status = RESET_STATUS; dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; _line_size = AUDIO_LINE_SIZE; if (dev->input_audiofilename) { str_length = strlen(dev->input_audiofilename); dev->_audiofilename = (char *)kmalloc(str_length + 1, GFP_KERNEL); if (!dev->_audiofilename) goto error; memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1); //Default if filename is empty string if (strcmp(dev->input_audiofilename, "") == 0) { dev->_audiofilename = "/root/audioGOOD.wav"; } } else { str_length = strlen(_defaultAudioName); dev->_audiofilename = (char *)kmalloc(str_length + 1, GFP_KERNEL); if (!dev->_audiofilename) goto error; memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1); } retval = cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, _line_size, 0); dev->audio_upstream_riscbuf_size = AUDIO_RISC_DMA_BUF_SIZE * NUM_AUDIO_PROGS + RISC_SYNC_INSTRUCTION_SIZE; dev->audio_upstream_databuf_size = AUDIO_DATA_BUF_SZ * NUM_AUDIO_PROGS; //Allocating buffers and prepare RISC program retval = cx25821_audio_upstream_buffer_prepare(dev, sram_ch, _line_size); if (retval < 0) { printk(KERN_ERR "%s: Failed to set up Audio upstream buffers!\n", dev->name); goto error; } //Start RISC engine cx25821_start_audio_dma_upstream(dev, sram_ch); return 0; error: cx25821_dev_unregister(dev); return err; }