Custom SDMA script to convert bayer image

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom SDMA script to convert bayer image

1,830 Views
chrisroed
Contributor IV

Hello Freescale folks,

First some background

I an IMX6Solo running the 3.14.28 wandboard kernel image which has been modified to aquire bayer image data.  I currently have a system that can aquire bayer video and convert it to RGBx format using the bayer2rgb gstreamer plugin, however the CPU is almost at 100% usage for a 640x480 video stream, and I need a 1280x720 video.   It looks like the other people who've had to convert bayer2rgb were using dual/quad core CPUs so they had enough horsepower to get it done, but I don't have that luxury.

I think it may be possible to use the SDMA engine to do this conversion for me by loading in the data, performing some shifts and masks to realize a nearest neighbor type of algorithm and then writing out the date to an output buffer.  These types of opcodes are all available in the SDMA engine, so I'm excited to try this out.  I'd need to have the SDMA available from a gstreamer plugin in order for this to work.

I've been reading a blog ( Freescale i.MX SDMA tutorial (part IV) )  that has some excellent information on the freescale SDMA system, but it was written 4 years ago and there are quite a few changes to the kernel code since then.

I guess the first question is, for anyone familiar with the SDMA system, is this even possible, and how can I get a hold of the freescale assembler to write my custom script? 

Next question:  In the blog I linked to, the guy wrote a function to load his script and run it, but he put it at the end of the sdma_probe function.  I need whatever function I'm going to use accessible from a gstreamer plugin, and I need to give it variables for the src/dest address.  If I write this function, and declare it in the include/linux/platform_data/dma-imx-sdma.h file would it be accessible to a gstreamer plugin?

I'm open to any other suggests for converting the data if anyone has them!

Thanks!

Labels (5)
Tags (1)
0 Kudos
4 Replies

945 Views
igorpadykov
NXP Employee
NXP Employee

Hi Chris

for SDMA software one can look at

http://cache.freescale.com/files/soft_dev_tools/doc/data_sheet/950-00140.pdf

In general sdma script can be loaded from any application, so one can put it

to gstreamer plugin sources too.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

945 Views
chrisroed
Contributor IV

Hi igorpadykov

It turns out I needed to enable the clocks before letting the channels run... :-).

So now that I'm able to load and run a script, from kernel space, I need to be able to load scripts and modify contexts from user space.  You said earlier that applications should be able to load scripts, so do you have any examples of this or know how to set this up?

-Thanks!

0 Kudos

945 Views
chrisroed
Contributor IV

Igor,

It looks like after the first usage of sdma_run_channel0 to load the firmware file, the HE[0] bit is never set.

Both functions are calling the sdma_run_channel0, so why is only the first try enabling the HE[0] bit?

[    0.206740] imx-sdma 20ec000.sdma: no iram assigned, using external mem

[    0.206851] imx-sdma 20ec000.sdma: no event needs to be remapped

[    0.206931] imx-sdma 20ec000.sdma: HE: 0x1

[    0.206941] imx-sdma 20ec000.sdma: EO: 0x1

[    0.206950] imx-sdma 20ec000.sdma: DO: 0xffffffff

[    0.206957] imx-sdma 20ec000.sdma: HO: 0x0

[    0.207009] imx-sdma 20ec000.sdma: loaded firmware 3.1

[    0.210025] imx-sdma 20ec000.sdma: initialized

[    0.210087] imx-sdma 20ec000.sdma: sdma_write_datamem:

[    0.210128] imx-sdma 20ec000.sdma: HE: 0x0    

[    0.210138] imx-sdma 20ec000.sdma: EO: 0x1

[    0.210146] imx-sdma 20ec000.sdma: DO: 0xffffffff

[    0.210155] imx-sdma 20ec000.sdma: HO: 0x0

[    0.221963] imx-sdma 20ec000.sdma: sdma_run_channel0 Timeout waiting for CH0 ready

[    0.222019] imx-sdma 20ec000.sdma: sdma_write_datamem:

[    0.222057] imx-sdma 20ec000.sdma: HE: 0x0

[    0.222066] imx-sdma 20ec000.sdma: EO: 0x1

[    0.222075] imx-sdma 20ec000.sdma: DO: 0xffffffff

[    0.222082] imx-sdma 20ec000.sdma: HO: 0x0

[    0.233805] imx-sdma 20ec000.sdma: sdma_run_channel0 Timeout waiting for CH0 ready

[    0.233818] imx-sdma 20ec000.sdma: Failed to load context

0 Kudos

945 Views
chrisroed
Contributor IV

Hi Igor, thanks for the response.  So put some code from that blog into my kernel, with a few changes to account for the 3.14 kernel.  I'm running into a timeout when I try to load the scripts.  I noticed that the author of that blog wrote his own sdma_write_datamem function instead of using the sdma_load_script function.  I've tried both of these functions and they both result in a CH0 timeout.  I increased the timeout from 500uS to 10mS and it still timed out.  I added some debug messages to the sdma_load_script function.

I'm trying to run the attached code snippet at the end of the sdma_probe function.  It uses CH0 to load a script and load a context, then uses CH1 to do a simple DMA transfer.

The relevant dmesg out put is

**** This is the standard driver probe.  sdma_load_script is called and functions normally****

[    0.206708] imx-sdma 20ec000.sdma: no iram assigned, using external mem

[    0.206818] imx-sdma 20ec000.sdma: no event needs to be remapped

[    0.206862] imx-sdma 20ec000.sdma: sdma_load_script:

[    0.206873] imx-sdma 20ec000.sdma:   src address: 0x805a43d4

[    0.206882] imx-sdma 20ec000.sdma:   size: 1864

[    0.206889] imx-sdma 20ec000.sdma:   dest address: 0x1800

[    0.207015] imx-sdma 20ec000.sdma: loaded firmware 3.1

[    0.210077] imx-sdma 20ec000.sdma: initialized

********* trying to load the custom script into 0xe00 and context for sdmac 1 into 0x820 **********************

[    0.210142] imx-sdma 20ec000.sdma: sdma_load_script:

[    0.210152] imx-sdma 20ec000.sdma:   src address: 0x80576ae4

[    0.210160] imx-sdma 20ec000.sdma:   size: 24

[    0.210168] imx-sdma 20ec000.sdma:   dest address: 0xe00

[    0.221998] imx-sdma 20ec000.sdma: sdma_run_channel0 Timeout waiting for CH0 ready

[    0.222118] imx-sdma 20ec000.sdma: sdma_load_script:

[    0.222129] imx-sdma 20ec000.sdma:   src address: 0x8c079200

[    0.222138] imx-sdma 20ec000.sdma:   size: 128

[    0.222145] imx-sdma 20ec000.sdma:   dest address: 0x820

[    0.233958] imx-sdma 20ec000.sdma: sdma_run_channel0 Timeout waiting for CH0 ready

[    0.234024] imx-sdma 20ec000.sdma: Failed to load context

Any ideas on why I can't load the scripts into memory?

0 Kudos