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