diff options
Diffstat (limited to 'drivers/media/video/cx25821/cx25821-video-upstream.c')
-rw-r--r-- | drivers/media/video/cx25821/cx25821-video-upstream.c | 156 |
1 files changed, 64 insertions, 92 deletions
diff --git a/drivers/media/video/cx25821/cx25821-video-upstream.c b/drivers/media/video/cx25821/cx25821-video-upstream.c index c0b80068f46..21e7d657f04 100644 --- a/drivers/media/video/cx25821/cx25821-video-upstream.c +++ b/drivers/media/video/cx25821/cx25821-video-upstream.c | |||
@@ -136,7 +136,7 @@ static __le32 *cx25821_risc_field_upstream(struct cx25821_dev *dev, __le32 * rp, | |||
136 | { | 136 | { |
137 | unsigned int line, i; | 137 | unsigned int line, i; |
138 | struct sram_channel *sram_ch = | 138 | struct sram_channel *sram_ch = |
139 | dev->channels[dev->_channel_upstream_select].sram_channels; | 139 | dev->channels[dev->_channel_upstream_select].sram_channels; |
140 | int dist_betwn_starts = bpl * 2; | 140 | int dist_betwn_starts = bpl * 2; |
141 | 141 | ||
142 | /* sync instruction */ | 142 | /* sync instruction */ |
@@ -194,15 +194,12 @@ int cx25821_risc_buffer_upstream(struct cx25821_dev *dev, | |||
194 | if (dev->_isNTSC) { | 194 | if (dev->_isNTSC) { |
195 | odd_num_lines = singlefield_lines + 1; | 195 | odd_num_lines = singlefield_lines + 1; |
196 | risc_program_size = FRAME1_VID_PROG_SIZE; | 196 | risc_program_size = FRAME1_VID_PROG_SIZE; |
197 | frame_size = | 197 | frame_size = (bpl == Y411_LINE_SZ) ? |
198 | (bpl == | 198 | FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; |
199 | Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : | ||
200 | FRAME_SIZE_NTSC_Y422; | ||
201 | } else { | 199 | } else { |
202 | risc_program_size = PAL_VID_PROG_SIZE; | 200 | risc_program_size = PAL_VID_PROG_SIZE; |
203 | frame_size = | 201 | frame_size = (bpl == Y411_LINE_SZ) ? |
204 | (bpl == | 202 | FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; |
205 | Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; | ||
206 | } | 203 | } |
207 | 204 | ||
208 | /* Virtual address of Risc buffer program */ | 205 | /* Virtual address of Risc buffer program */ |
@@ -214,13 +211,9 @@ int cx25821_risc_buffer_upstream(struct cx25821_dev *dev, | |||
214 | if (UNSET != top_offset) { | 211 | if (UNSET != top_offset) { |
215 | fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; | 212 | fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; |
216 | rp = cx25821_risc_field_upstream(dev, rp, | 213 | rp = cx25821_risc_field_upstream(dev, rp, |
217 | dev-> | 214 | dev->_data_buf_phys_addr + |
218 | _data_buf_phys_addr + | 215 | databuf_offset, top_offset, 0, bpl, |
219 | databuf_offset, | 216 | odd_num_lines, fifo_enable, ODD_FIELD); |
220 | top_offset, 0, bpl, | ||
221 | odd_num_lines, | ||
222 | fifo_enable, | ||
223 | ODD_FIELD); | ||
224 | } | 217 | } |
225 | 218 | ||
226 | fifo_enable = FIFO_DISABLE; | 219 | fifo_enable = FIFO_DISABLE; |
@@ -234,8 +227,8 @@ int cx25821_risc_buffer_upstream(struct cx25821_dev *dev, | |||
234 | 227 | ||
235 | if (frame == 0) { | 228 | if (frame == 0) { |
236 | risc_flag = RISC_CNT_RESET; | 229 | risc_flag = RISC_CNT_RESET; |
237 | risc_phys_jump_addr = | 230 | risc_phys_jump_addr = dev->_dma_phys_start_addr + |
238 | dev->_dma_phys_start_addr + risc_program_size; | 231 | risc_program_size; |
239 | } else { | 232 | } else { |
240 | risc_phys_jump_addr = dev->_dma_phys_start_addr; | 233 | risc_phys_jump_addr = dev->_dma_phys_start_addr; |
241 | risc_flag = RISC_CNT_INC; | 234 | risc_flag = RISC_CNT_INC; |
@@ -255,7 +248,7 @@ int cx25821_risc_buffer_upstream(struct cx25821_dev *dev, | |||
255 | void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev) | 248 | void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev) |
256 | { | 249 | { |
257 | struct sram_channel *sram_ch = | 250 | struct sram_channel *sram_ch = |
258 | dev->channels[VID_UPSTREAM_SRAM_CHANNEL_I].sram_channels; | 251 | dev->channels[VID_UPSTREAM_SRAM_CHANNEL_I].sram_channels; |
259 | u32 tmp = 0; | 252 | u32 tmp = 0; |
260 | 253 | ||
261 | if (!dev->_is_running) { | 254 | if (!dev->_is_running) { |
@@ -312,9 +305,8 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
312 | struct file *myfile; | 305 | struct file *myfile; |
313 | int frame_index_temp = dev->_frame_index; | 306 | int frame_index_temp = dev->_frame_index; |
314 | int i = 0; | 307 | int i = 0; |
315 | int line_size = | 308 | int line_size = (dev->_pixel_format == PIXEL_FRMT_411) ? |
316 | (dev->_pixel_format == | 309 | Y411_LINE_SZ : Y422_LINE_SZ; |
317 | PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; | ||
318 | int frame_size = 0; | 310 | int frame_size = 0; |
319 | int frame_offset = 0; | 311 | int frame_offset = 0; |
320 | ssize_t vfs_read_retval = 0; | 312 | ssize_t vfs_read_retval = 0; |
@@ -326,16 +318,12 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
326 | if (dev->_file_status == END_OF_FILE) | 318 | if (dev->_file_status == END_OF_FILE) |
327 | return 0; | 319 | return 0; |
328 | 320 | ||
329 | if (dev->_isNTSC) { | 321 | if (dev->_isNTSC) |
330 | frame_size = | 322 | frame_size = (line_size == Y411_LINE_SZ) ? |
331 | (line_size == | 323 | FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; |
332 | Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : | 324 | else |
333 | FRAME_SIZE_NTSC_Y422; | 325 | frame_size = (line_size == Y411_LINE_SZ) ? |
334 | } else { | 326 | FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; |
335 | frame_size = | ||
336 | (line_size == | ||
337 | Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; | ||
338 | } | ||
339 | 327 | ||
340 | frame_offset = (frame_index_temp > 0) ? frame_size : 0; | 328 | frame_offset = (frame_index_temp > 0) ? frame_size : 0; |
341 | file_offset = dev->_frame_count * frame_size; | 329 | file_offset = dev->_frame_count * frame_size; |
@@ -369,8 +357,8 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
369 | for (i = 0; i < dev->_lines_count; i++) { | 357 | for (i = 0; i < dev->_lines_count; i++) { |
370 | pos = file_offset; | 358 | pos = file_offset; |
371 | 359 | ||
372 | vfs_read_retval = | 360 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, |
373 | vfs_read(myfile, mybuf, line_size, &pos); | 361 | &pos); |
374 | 362 | ||
375 | if (vfs_read_retval > 0 && vfs_read_retval == line_size | 363 | if (vfs_read_retval > 0 && vfs_read_retval == line_size |
376 | && dev->_data_buf_virt_addr != NULL) { | 364 | && dev->_data_buf_virt_addr != NULL) { |
@@ -392,8 +380,8 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
392 | if (i > 0) | 380 | if (i > 0) |
393 | dev->_frame_count++; | 381 | dev->_frame_count++; |
394 | 382 | ||
395 | dev->_file_status = | 383 | dev->_file_status = (vfs_read_retval == line_size) ? |
396 | (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 384 | IN_PROGRESS : END_OF_FILE; |
397 | 385 | ||
398 | set_fs(old_fs); | 386 | set_fs(old_fs); |
399 | filp_close(myfile, NULL); | 387 | filp_close(myfile, NULL); |
@@ -404,8 +392,8 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
404 | 392 | ||
405 | static void cx25821_vidups_handler(struct work_struct *work) | 393 | static void cx25821_vidups_handler(struct work_struct *work) |
406 | { | 394 | { |
407 | struct cx25821_dev *dev = | 395 | struct cx25821_dev *dev = container_of(work, struct cx25821_dev, |
408 | container_of(work, struct cx25821_dev, _irq_work_entry); | 396 | _irq_work_entry); |
409 | 397 | ||
410 | if (!dev) { | 398 | if (!dev) { |
411 | pr_err("ERROR %s(): since container_of(work_struct) FAILED!\n", | 399 | pr_err("ERROR %s(): since container_of(work_struct) FAILED!\n", |
@@ -413,18 +401,16 @@ static void cx25821_vidups_handler(struct work_struct *work) | |||
413 | return; | 401 | return; |
414 | } | 402 | } |
415 | 403 | ||
416 | cx25821_get_frame(dev, | 404 | cx25821_get_frame(dev, dev->channels[dev->_channel_upstream_select]. |
417 | dev->channels[dev->_channel_upstream_select]. | 405 | sram_channels); |
418 | sram_channels); | ||
419 | } | 406 | } |
420 | 407 | ||
421 | int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) | 408 | int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) |
422 | { | 409 | { |
423 | struct file *myfile; | 410 | struct file *myfile; |
424 | int i = 0, j = 0; | 411 | int i = 0, j = 0; |
425 | int line_size = | 412 | int line_size = (dev->_pixel_format == PIXEL_FRMT_411) ? |
426 | (dev->_pixel_format == | 413 | Y411_LINE_SZ : Y422_LINE_SZ; |
427 | PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; | ||
428 | ssize_t vfs_read_retval = 0; | 414 | ssize_t vfs_read_retval = 0; |
429 | char mybuf[line_size]; | 415 | char mybuf[line_size]; |
430 | loff_t pos; | 416 | loff_t pos; |
@@ -461,8 +447,8 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
461 | for (i = 0; i < dev->_lines_count; i++) { | 447 | for (i = 0; i < dev->_lines_count; i++) { |
462 | pos = offset; | 448 | pos = offset; |
463 | 449 | ||
464 | vfs_read_retval = | 450 | vfs_read_retval = vfs_read(myfile, mybuf, |
465 | vfs_read(myfile, mybuf, line_size, &pos); | 451 | line_size, &pos); |
466 | 452 | ||
467 | if (vfs_read_retval > 0 | 453 | if (vfs_read_retval > 0 |
468 | && vfs_read_retval == line_size | 454 | && vfs_read_retval == line_size |
@@ -489,8 +475,8 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
489 | break; | 475 | break; |
490 | } | 476 | } |
491 | 477 | ||
492 | dev->_file_status = | 478 | dev->_file_status = (vfs_read_retval == line_size) ? |
493 | (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 479 | IN_PROGRESS : END_OF_FILE; |
494 | 480 | ||
495 | set_fs(old_fs); | 481 | set_fs(old_fs); |
496 | myfile->f_pos = 0; | 482 | myfile->f_pos = 0; |
@@ -507,14 +493,12 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
507 | dma_addr_t dma_addr; | 493 | dma_addr_t dma_addr; |
508 | dma_addr_t data_dma_addr; | 494 | dma_addr_t data_dma_addr; |
509 | 495 | ||
510 | if (dev->_dma_virt_addr != NULL) { | 496 | if (dev->_dma_virt_addr != NULL) |
511 | pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, | 497 | pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, |
512 | dev->_dma_virt_addr, dev->_dma_phys_addr); | 498 | dev->_dma_virt_addr, dev->_dma_phys_addr); |
513 | } | ||
514 | 499 | ||
515 | dev->_dma_virt_addr = | 500 | dev->_dma_virt_addr = pci_alloc_consistent(dev->pci, |
516 | pci_alloc_consistent(dev->pci, dev->upstream_riscbuf_size, | 501 | dev->upstream_riscbuf_size, &dma_addr); |
517 | &dma_addr); | ||
518 | dev->_dma_virt_start_addr = dev->_dma_virt_addr; | 502 | dev->_dma_virt_start_addr = dev->_dma_virt_addr; |
519 | dev->_dma_phys_start_addr = dma_addr; | 503 | dev->_dma_phys_start_addr = dma_addr; |
520 | dev->_dma_phys_addr = dma_addr; | 504 | dev->_dma_phys_addr = dma_addr; |
@@ -528,15 +512,13 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
528 | /* Clear memory at address */ | 512 | /* Clear memory at address */ |
529 | memset(dev->_dma_virt_addr, 0, dev->_risc_size); | 513 | memset(dev->_dma_virt_addr, 0, dev->_risc_size); |
530 | 514 | ||
531 | if (dev->_data_buf_virt_addr != NULL) { | 515 | if (dev->_data_buf_virt_addr != NULL) |
532 | pci_free_consistent(dev->pci, dev->upstream_databuf_size, | 516 | pci_free_consistent(dev->pci, dev->upstream_databuf_size, |
533 | dev->_data_buf_virt_addr, | 517 | dev->_data_buf_virt_addr, |
534 | dev->_data_buf_phys_addr); | 518 | dev->_data_buf_phys_addr); |
535 | } | ||
536 | /* For Video Data buffer allocation */ | 519 | /* For Video Data buffer allocation */ |
537 | dev->_data_buf_virt_addr = | 520 | dev->_data_buf_virt_addr = pci_alloc_consistent(dev->pci, |
538 | pci_alloc_consistent(dev->pci, dev->upstream_databuf_size, | 521 | dev->upstream_databuf_size, &data_dma_addr); |
539 | &data_dma_addr); | ||
540 | dev->_data_buf_phys_addr = data_dma_addr; | 522 | dev->_data_buf_phys_addr = data_dma_addr; |
541 | dev->_data_buf_size = dev->upstream_databuf_size; | 523 | dev->_data_buf_size = dev->upstream_databuf_size; |
542 | 524 | ||
@@ -553,9 +535,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
553 | return ret; | 535 | return ret; |
554 | 536 | ||
555 | /* Create RISC programs */ | 537 | /* Create RISC programs */ |
556 | ret = | 538 | ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, |
557 | cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, | 539 | dev->_lines_count); |
558 | dev->_lines_count); | ||
559 | if (ret < 0) { | 540 | if (ret < 0) { |
560 | pr_info("Failed creating Video Upstream Risc programs!\n"); | 541 | pr_info("Failed creating Video Upstream Risc programs!\n"); |
561 | goto error; | 542 | goto error; |
@@ -672,10 +653,9 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id) | |||
672 | vid_status = cx_read(sram_ch->int_stat); | 653 | vid_status = cx_read(sram_ch->int_stat); |
673 | 654 | ||
674 | /* Only deal with our interrupt */ | 655 | /* Only deal with our interrupt */ |
675 | if (vid_status) { | 656 | if (vid_status) |
676 | handled = | 657 | handled = cx25821_video_upstream_irq(dev, channel_num, |
677 | cx25821_video_upstream_irq(dev, channel_num, vid_status); | 658 | vid_status); |
678 | } | ||
679 | 659 | ||
680 | if (handled < 0) | 660 | if (handled < 0) |
681 | cx25821_stop_upstream_video_ch1(dev); | 661 | cx25821_stop_upstream_video_ch1(dev); |
@@ -747,8 +727,7 @@ int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, | |||
747 | tmp = cx_read(sram_ch->int_msk); | 727 | tmp = cx_read(sram_ch->int_msk); |
748 | cx_write(sram_ch->int_msk, tmp |= _intr_msk); | 728 | cx_write(sram_ch->int_msk, tmp |= _intr_msk); |
749 | 729 | ||
750 | err = | 730 | err = request_irq(dev->pci->irq, cx25821_upstream_irq, |
751 | request_irq(dev->pci->irq, cx25821_upstream_irq, | ||
752 | IRQF_SHARED, dev->name, dev); | 731 | IRQF_SHARED, dev->name, dev); |
753 | if (err < 0) { | 732 | if (err < 0) { |
754 | pr_err("%s: can't get upstream IRQ %d\n", | 733 | pr_err("%s: can't get upstream IRQ %d\n", |
@@ -807,43 +786,38 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, | |||
807 | dev->_file_status = RESET_STATUS; | 786 | dev->_file_status = RESET_STATUS; |
808 | dev->_lines_count = dev->_isNTSC ? 480 : 576; | 787 | dev->_lines_count = dev->_isNTSC ? 480 : 576; |
809 | dev->_pixel_format = pixel_format; | 788 | dev->_pixel_format = pixel_format; |
810 | dev->_line_size = | 789 | dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ? |
811 | (dev->_pixel_format == | 790 | (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; |
812 | PIXEL_FRMT_422) ? (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; | ||
813 | data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; | 791 | data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; |
814 | risc_buffer_size = | 792 | risc_buffer_size = dev->_isNTSC ? |
815 | dev->_isNTSC ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; | 793 | NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; |
816 | 794 | ||
817 | if (dev->input_filename) { | 795 | if (dev->input_filename) { |
818 | str_length = strlen(dev->input_filename); | 796 | str_length = strlen(dev->input_filename); |
819 | dev->_filename = kmalloc(str_length + 1, GFP_KERNEL); | 797 | dev->_filename = kmemdup(dev->input_filename, str_length + 1, |
798 | GFP_KERNEL); | ||
820 | 799 | ||
821 | if (!dev->_filename) | 800 | if (!dev->_filename) |
822 | goto error; | 801 | goto error; |
823 | |||
824 | memcpy(dev->_filename, dev->input_filename, str_length + 1); | ||
825 | } else { | 802 | } else { |
826 | str_length = strlen(dev->_defaultname); | 803 | str_length = strlen(dev->_defaultname); |
827 | dev->_filename = kmalloc(str_length + 1, GFP_KERNEL); | 804 | dev->_filename = kmemdup(dev->_defaultname, str_length + 1, |
805 | GFP_KERNEL); | ||
828 | 806 | ||
829 | if (!dev->_filename) | 807 | if (!dev->_filename) |
830 | goto error; | 808 | goto error; |
831 | |||
832 | memcpy(dev->_filename, dev->_defaultname, str_length + 1); | ||
833 | } | 809 | } |
834 | 810 | ||
835 | /* Default if filename is empty string */ | 811 | /* Default if filename is empty string */ |
836 | if (strcmp(dev->input_filename, "") == 0) { | 812 | if (strcmp(dev->input_filename, "") == 0) { |
837 | if (dev->_isNTSC) { | 813 | if (dev->_isNTSC) { |
838 | dev->_filename = | 814 | dev->_filename = |
839 | (dev->_pixel_format == | 815 | (dev->_pixel_format == PIXEL_FRMT_411) ? |
840 | PIXEL_FRMT_411) ? "/root/vid411.yuv" : | 816 | "/root/vid411.yuv" : "/root/vidtest.yuv"; |
841 | "/root/vidtest.yuv"; | ||
842 | } else { | 817 | } else { |
843 | dev->_filename = | 818 | dev->_filename = |
844 | (dev->_pixel_format == | 819 | (dev->_pixel_format == PIXEL_FRMT_411) ? |
845 | PIXEL_FRMT_411) ? "/root/pal411.yuv" : | 820 | "/root/pal411.yuv" : "/root/pal422.yuv"; |
846 | "/root/pal422.yuv"; | ||
847 | } | 821 | } |
848 | } | 822 | } |
849 | 823 | ||
@@ -852,13 +826,11 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, | |||
852 | dev->_file_status = RESET_STATUS; | 826 | dev->_file_status = RESET_STATUS; |
853 | dev->_lines_count = dev->_isNTSC ? 480 : 576; | 827 | dev->_lines_count = dev->_isNTSC ? 480 : 576; |
854 | dev->_pixel_format = pixel_format; | 828 | dev->_pixel_format = pixel_format; |
855 | dev->_line_size = | 829 | dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ? |
856 | (dev->_pixel_format == | 830 | (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; |
857 | PIXEL_FRMT_422) ? (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; | ||
858 | 831 | ||
859 | retval = | 832 | retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, |
860 | cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size, | 833 | dev->_line_size, 0); |
861 | 0); | ||
862 | 834 | ||
863 | /* setup fifo + format */ | 835 | /* setup fifo + format */ |
864 | cx25821_set_pixelengine(dev, sram_ch, dev->_pixel_format); | 836 | cx25821_set_pixelengine(dev, sram_ch, dev->_pixel_format); |