Merge branch 'org.openembedded.dev' of git@git.openembedded.net:openembedded into...
[openembedded.git] / packages / dsplink / ti-codec-engine_2.21.bb
1 require dsplink.inc
2
3 DESCRIPTION = "Codec Engine for TI ARM/DSP processors"
4
5 DEPENDS = "virtual/kernel perl-native"
6 RDEPENDS = "update-modules"
7
8 inherit module
9
10 # tconf from xdctools dislikes '.' in pwd :/
11 PR = "r14"
12 PV = "221"
13
14 # Get CE tarball from TI website, place in sources and calculate
15 # md5sum
16 # Look for tarball at https://www-a.ti.com/downloads/sds_support/targetcontent/CE/index.html
17
18 SRC_URI = "http://install.tarball.in.source.dir/codec_engine_2_21.tar.gz \
19            file://cmem-class-device-27-and-sched-include-fix.patch;patch=1 \
20            file://sdma-class-device-and-includes-fix.patch;patch=1 \
21            file://dsplink-semaphore-27.patch;patch=1 \
22            file://lpm-device-create-and-semaphore-include-fix.patch;patch=1 \
23            file://lpm-make-symbol-warnings-fix.patch;patch=1 \
24            file://Makefile-dsplink-gpp \
25            file://Makefile-dsplink-dsp \
26            file://loadmodules-ti-dsplink-apps.sh \
27            file://unloadmodules-ti-dsplink-apps.sh \
28            file://loadmodules-ti-codec-engine-apps.sh \
29            file://unloadmodules-ti-codec-engine-apps.sh \
30 "
31
32 S = "${WORKDIR}/codec_engine_2_21"
33
34 require ti-paths.inc
35
36 export DSPLINK="${S}/cetools/packages/dsplink"
37
38 PARALLEL_MAKE = ""
39
40 # the include files on top define do_compile for the submodules 
41 do_compile_append() {
42
43 #dsplink already done from inclusion of require dsplink.inc
44
45 #lpm bits
46         if [ -e ${S}/cetools/packages/ti/bios/power/ ] ; then
47                 
48                 # Build the DSP power manager kernel module
49                 cd ${S}/cetools/packages/ti/bios/power/modules/${DSPPOWERSOC}/lpm
50
51                 # Still need to move this into the patch file
52                 if [ $(echo ${KERNEL_VERSION} | cut -c5,6) -gt 26 ] ; then
53                         sed -i -e s:asm/semaphore:linux/semaphore: lpm_driver.c
54                 fi
55
56                 #what is this for?
57                 rm -f *o
58                 
59                 # lpm also needs KERNEL_INSTALL_DIR and MVTOOL_PREFIX which come from ti-paths.inc
60                 export DSPLINK_REPO=${DSPLINK}/..
61                 # should move the clean step into the clean stage..
62                 #oe_runmake clean
63                 oe_runmake
64         fi
65
66 #cmemk bits
67         if [ -e ${S}/cetools/packages/ti/sdo/linuxutils/cmem ] ; then
68                 echo "MVTOOL_PREFIX=${TARGET_PREFIX}" > ${S}/Rules.make
69                 echo "UCTOOL_PREFIX=${TARGET_PREFIX}" >> ${S}/Rules.make
70                 echo "LINUXKERNEL_INSTALL_DIR=${STAGING_KERNEL_DIR}"  >> ${S}/Rules.make
71                 #export DSPLINK=${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/dsplink
72
73                 # Build the cmem kernel module and associated test apps
74                 # We unset CFLAGS because kernel modules need different ones, this is basically a verbatim copy of kernel.bbclass and module-base.bbclass       
75                 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS  
76
77                 cd ${S}/cetools/packages/ti/sdo/linuxutils/cmem
78                 oe_runmake clean
79                 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR}   \
80                 KERNEL_SRC=${STAGING_KERNEL_DIR}    \
81                 KERNEL_VERSION=${KERNEL_VERSION}    \
82                 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
83                 AR="${KERNEL_AR}"
84         fi
85
86 #sdma bits
87         if [ -e ${S}/cetools/packages/ti/sdo/linuxutils/sdma ] ; then
88                echo "MVTOOL_PREFIX=${TARGET_PREFIX}" > ${S}/Rules.make
89                echo "UCTOOL_PREFIX=${TARGET_PREFIX}" >> ${S}/Rules.make
90                echo "LINUXKERNEL_INSTALL_DIR=${STAGING_KERNEL_DIR}"  >> ${S}/Rules.make
91
92                 # Build the sdma kernel module and associated test apps
93                 # We unset CFLAGS because kernel modules need different ones, this is basically a verbatim copy of kernel.bbclass and module-base.bbclass
94                 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
95
96                 cd ${S}/cetools/packages/ti/sdo/linuxutils/sdma
97                 oe_runmake clean
98                 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR}   \
99                 KERNEL_SRC=${STAGING_KERNEL_DIR}    \
100                 KERNEL_VERSION=${KERNEL_VERSION}    \
101                 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
102                 AR="${KERNEL_AR}"
103         fi
104
105
106 #need to add other modules here, like IRQ, etc
107
108
109 #now build the CE examples
110         cd ${S}/examples
111
112         # Fix paths to arm crosstools, c6x codegen and x86 gcc
113         # Also disable uclibc and x86 builds
114         sed -i -e s:/db/toolsrc/library/tools/vendors/cs/arm/arm-2007q3:${CROSS_DIR}:g \
115         -e s:/db/toolsrc/library/tools/vendors/ti/c6x/6.0.16/Linux:${TITOOLSDIR}/${TICGTOOLSDIR}:g \
116         -e s:/db/toolsrc/library/tools/vendors/opensource/gcc/4.1.0/Linux/gcc-4.1.0-glibc-2.3.6/i686-unknown-linux-gnu:/usr:g \
117         -e s:arm-none-linux-gnueabi-:${TARGET_PREFIX}:g \
118         -e 's:true, // build for uC Linux:false,:g' \
119         -e 's:true,  // build for PC Linux:false,:g' \
120         ${S}/examples/user.bld
121
122         # For now, remove all targets, except dm6446 and omap3530
123         sed -i \
124         -e '/evmDM357/d' \
125         -e '/evmDM6446/d' \
126         -e '/evmDM6467/d' \
127         -e '/evmDM355/d' \
128         -e '/evmDM6437/d' \
129         -e '/evmDM648/d' \
130         -e '/sdp3430/d' \
131         -e '/evm2530/d' \
132         ${S}/examples/user.bld
133
134         # Fix path to c6x codegen
135         sed -i -e s:/db/toolsrc/library/tools/vendors/ti/c6x/6.0.16/Linux:${TITOOLSDIR}/${TICGTOOLSDIR}:g \
136                 xdcpaths.mak
137         
138         # Start building the CE examples: codecs, extensions, servers (codec bundles) and ARM side apps 
139         # the DSP side uses CC to point to the c6x codegen, but would get the gcc tool
140         unset CC
141
142         # Make clean doesn't do what you'd expect, it only cleans stuff you've enabled, so some cruft remains   
143
144         # First clean
145         for i in codecs extensions servers apps ; do
146                 make -e -C ${S}/examples/ti/sdo/ce/examples/$i clean
147         done    
148
149         # Then build the examples
150         for i in codecs extensions servers apps ; do
151                 make -e -C ${S}/examples/ti/sdo/ce/examples/$i
152         done
153 }
154
155 do_install_append () {
156     #driver - kernel module
157         install -d ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp
158         cp ${S}/cetools/packages/ti/bios/power/modules/${DSPPOWERSOC}/lpm/*.ko ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp || true
159         cp ${S}/cetools/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.ko ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp || true
160         cp ${S}/cetools/packages/ti/sdo/linuxutils/sdma/src/module/sdmak.ko ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp || true
161
162     #library
163         #install -d ${D}/${libdir}
164         #install -m 0755 ${DSPLINK}/gpp/BUILD/EXPORT/RELEASE/dsplink.lib  ${D}/${libdir}
165
166     #sample apps - this is very 64x / v5T specific at the moment - we really need CE to give us this list...
167         install -d ${D}/${datadir}/ti-codec-engine
168         # we change pwd so that find gives us relative path to the files, which we use to create the same structure on the target
169         cd ${S}/examples/ti/sdo/ce
170
171     #test app module un/load scripts
172         install ${WORKDIR}/loadmodules-ti-dsplink-apps.sh ${D}/${datadir}/ti-dsplink
173         install ${WORKDIR}/unloadmodules-ti-dsplink-apps.sh ${D}/${datadir}/ti-dsplink
174
175     #ce samples
176         # first find all the app files named '.out'
177         for i in $(find . -name "*.out") ; do
178                 # first create the directory
179                 install -d ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
180                 # now copy the file             
181                 install ${i} ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
182         done
183
184         # next find all the app files named '.xv5T'
185         for i in $(find . -name "*.xv5T") ; do
186                 # first create the directory
187                 install -d ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
188                 # now copy the file             
189                 install ${i} ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
190         done
191
192         # then find all the app/server files named '.x64P'
193         for i in $(find . -name "*.x64P") ; do
194                 # first create the directory
195                 install -d ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
196                 # now copy the file             
197                 install ${i} ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
198         done
199
200         # finally find all the app files named '.dat'
201         for i in $(find . -name "*.dat") ; do
202                 # first create the directory
203                 install -d ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
204                 # now copy the file             
205                 install ${i} ${D}/${datadir}/ti-codec-engine/`dirname ${i}`
206         done
207
208     #test app module un/load scripts
209         install ${WORKDIR}/loadmodules-ti-codec-engine-apps.sh ${D}/${datadir}/ti-codec-engine
210         install ${WORKDIR}/unloadmodules-ti-codec-engine-apps.sh ${D}/${datadir}/ti-codec-engine
211
212         # we should install the CMEM apps as well here
213
214         # finally, strip targets that we're not supporting here
215         # - TODO...
216 }
217
218 PACKAGES =+ "ti-lpm-module ti-cmem-module ti-sdma-module ti-codec-engine-apps"
219
220 FILES_ti-lpm-module = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp/*lpm*ko"
221 FILES_ti-cmem-module = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp/cmemk.ko"
222 FILES_ti-sdma-moduke = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp/sdmak.ko"
223 FILES_ti-codec-engine-apps = "${datadir}/ti-codec-engine/*"
224
225 pkg_postinst_ti-lpm-module () {
226         if [ -n "$D" ]; then
227                 exit 1
228         fi
229         depmod -a
230         update-modules || true
231 }
232
233 pkg_postrm_ti-lpm-module () {
234         update-modules || true
235 }
236
237 pkg_postinst_ti-cmem-module () {
238         if [ -n "$D" ]; then        
239                 exit 1
240         fi
241         depmod -a
242         update-modules || true
243 }
244
245 pkg_postrm_ti-cmem-module () {
246         update-modules || true
247 }
248
249 pkg_postinst_ti-sdma-module () {
250         if [ -n "$D" ]; then
251                 exit 1
252         fi
253         depmod -a
254         update-modules || true
255 }
256
257 pkg_postrm_ti-sdma-module () {
258         update-modules || true
259 }
260
261 INHIBIT_PACKAGE_STRIP = "1"
262
263 PACKAGE_ARCH = "${MACHINE_ARCH}"
264
265 #legacy upgrade helpers
266 RPROVIDES_ti-cmem-module += "ti-cmemk-module"
267 RREPLACES_ti-cmem-module += "ti-cmemk-module"
268
269 # ti-dsplink-module can be built by either codec-engine or standalone dsplink - tell it to use this one, else unwanted dependence
270 PREFERRED_PROVIDER_ti-dsplink-module = "ti-codec-engine"
271
272 #add run-time dependencies - note for kernel module we can only use RRECOMMENDS, since modules might be built into the kernel
273 RRECOMMENDS_ti-codec-engine-apps += "ti-dsplink-module ti-lpm-module ti-cmem-module ti-sdma-module"
274