Advertisement
Guest User

Untitled

a guest
Feb 21st, 2010
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.14 KB | None | 0 0
  1. Index: lirc-0.8.6/debian/dkms.conf.in
  2. ===================================================================
  3. --- lirc-0.8.6.orig/debian/dkms.conf.in 2010-02-21 15:22:51.691411073 -0500
  4. +++ lirc-0.8.6/debian/dkms.conf.in 2010-02-21 15:23:05.161413684 -0500
  5. -63,3 +63,8 @@
  6. BUILT_MODULE_NAME[14]="lirc_ene0100"
  7. BUILT_MODULE_LOCATION[14]="modules"
  8. DEST_MODULE_LOCATION[14]="/updates/lirc"
  9. +
  10. +BUILT_MODULE_NAME[15]="lirc_zilog"
  11. +BUILT_MODULE_LOCATION[15]="modules"
  12. +DEST_MODULE_LOCATION[15]="/updates/lirc"
  13. +
  14. Index: lirc-0.8.6/debian/modules-source/Makefile
  15. ===================================================================
  16. --- lirc-0.8.6.orig/debian/modules-source/Makefile 2010-02-21 15:22:51.711390707 -0500
  17. +++ lirc-0.8.6/debian/modules-source/Makefile 2010-02-21 15:23:08.108913853 -0500
  18. -28,7 +28,7 @@
  19.  
  20. export KERNEL_LOCATION CC
  21.  
  22. -DRIVERS=atiusb bt829 gpio i2c igorplugusb imon it87 ite8709 mceusb parallel sasem serial sir streamzap ttusbir ene0100
  23. +DRIVERS=atiusb bt829 gpio i2c igorplugusb imon it87 ite8709 mceusb parallel sasem serial sir streamzap ttusbir ene0100 zilog
  24. all: $(DRIVERS)
  25.  
  26. test:
  27. -124,6 +124,11 @@
  28. cp drivers/lirc_mceusb/lirc_mceusb.$(KEXT) modules
  29. @echo $(KVERS) $(KSRC) > modules/lirc_mceusb.$(KEXT).KVERS
  30.  
  31. +zilog: modules sanity-check dev
  32. + $(MAKE) -C drivers SUBDIRS="lirc_zilog"
  33. + cp drivers/lirc_zilog/lirc_zilog.$(KEXT) modules
  34. + @echo $(KVERS) $(KSRC) > modules/lirc_zilog.$(KEXT).KVERS
  35. +
  36. parallel: DEFS += $(PARALLEL_CFLAGS)
  37. parallel: modules sanity-check dev
  38. $(MAKE) -C drivers SUBDIRS="lirc_parallel" DEFS="$(DEFS)"
  39. Index: lirc-0.8.6/debian/modules-source/lirc-modules-source.conf
  40. ===================================================================
  41. --- lirc-0.8.6.orig/debian/modules-source/lirc-modules-source.conf 2010-02-21 15:22:51.661406979 -0500
  42. +++ lirc-0.8.6/debian/modules-source/lirc-modules-source.conf 2010-02-21 15:23:01.811447768 -0500
  43. -2,7 +2,7 @@
  44.  
  45. # Comma separated list of lirc kernel drivers to build
  46. #gpio and parallel don't build
  47. -LIRC_MODULES="atiusb, bt829, i2c, igorplugusb, imon, it87, ite8709, mceusb, sasem, serial, sir, streamzap, ttusbir, ene0100"
  48. +LIRC_MODULES="atiusb, bt829, i2c, igorplugusb, imon, it87, ite8709, mceusb, sasem, serial, sir, streamzap, ttusbir, ene0100, zilog"
  49.  
  50. # It87 module configuration
  51. LIRC_IT87_CFLAGS=""
  52. Index: lirc-0.8.6/drivers/Makefile.in
  53. ===================================================================
  54. --- lirc-0.8.6.orig/drivers/Makefile.in 2010-02-21 15:22:51.731387802 -0500
  55. +++ lirc-0.8.6/drivers/Makefile.in 2010-02-21 15:23:10.968884323 -0500
  56. -137,6 +137,7 @@
  57. lirc_it87 \
  58. lirc_ite8709 \
  59. lirc_mceusb \
  60. + lirc_zilog \
  61. lirc_parallel \
  62. lirc_sasem \
  63. lirc_serial \
  64. Index: lirc-0.8.6/drivers/lirc_zilog/.deps/lirc_zilog.Po
  65. ===================================================================
  66. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  67. +++ lirc-0.8.6/drivers/lirc_zilog/.deps/lirc_zilog.Po 2010-02-21 15:23:08.108913853 -0500
  68. -0,0 +1 @@
  69. +# dummy
  70. Index: lirc-0.8.6/drivers/lirc_zilog/Makefile
  71. ===================================================================
  72. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  73. +++ lirc-0.8.6/drivers/lirc_zilog/Makefile 2010-02-21 15:25:03.108913783 -0500
  74. -0,0 +1,415 @@
  75. +# Makefile.in generated automatically by automake 1.5 from Makefile.am.
  76. +
  77. +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
  78. +# Free Software Foundation, Inc.
  79. +# This Makefile.in is free software; the Free Software Foundation
  80. +# gives unlimited permission to copy and/or distribute it,
  81. +# with or without modifications, as long as this notice is preserved.
  82. +
  83. +# This program is distributed in the hope that it will be useful,
  84. +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  85. +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  86. +# PARTICULAR PURPOSE.
  87. +
  88. +
  89. +
  90. +
  91. +# $Id: Makefile.common,v 5.10 2008/09/27 16:08:39 lirc Exp $
  92. +
  93. +# where the kernel sources are located
  94. +
  95. +SHELL = /bin/bash
  96. +
  97. +srcdir = .
  98. +top_srcdir = ../..
  99. +
  100. +prefix = /usr
  101. +exec_prefix = ${prefix}
  102. +
  103. +bindir = ${exec_prefix}/bin
  104. +sbindir = ${exec_prefix}/sbin
  105. +libexecdir = ${exec_prefix}/libexec
  106. +datadir = ${prefix}/share
  107. +sysconfdir = /etc/lirc/
  108. +sharedstatedir = ${prefix}/com
  109. +localstatedir = /var
  110. +libdir = ${prefix}/lib
  111. +infodir = ${prefix}/share/info
  112. +mandir = ${prefix}/share/man
  113. +includedir = ${prefix}/include
  114. +oldincludedir = /usr/include
  115. +pkgdatadir = $(datadir)/lirc
  116. +pkglibdir = $(libdir)/lirc
  117. +pkgincludedir = $(includedir)/lirc
  118. +top_builddir = ../..
  119. +
  120. +ACLOCAL = ${SHELL} /build/buildd/lirc-0.8.6/missing --run aclocal
  121. +AUTOCONF = ${SHELL} /build/buildd/lirc-0.8.6/missing --run autoconf
  122. +AUTOMAKE = ${SHELL} /build/buildd/lirc-0.8.6/missing --run automake
  123. +AUTOHEADER = ${SHELL} /build/buildd/lirc-0.8.6/missing --run autoheader
  124. +
  125. +INSTALL = /usr/bin/install -c
  126. +INSTALL_PROGRAM = ${INSTALL}
  127. +INSTALL_DATA = ${INSTALL} -m 644
  128. +INSTALL_SCRIPT = ${INSTALL}
  129. +INSTALL_HEADER = $(INSTALL_DATA)
  130. +transform = s,x,x,
  131. +NORMAL_INSTALL = :
  132. +PRE_INSTALL = :
  133. +POST_INSTALL = :
  134. +NORMAL_UNINSTALL = :
  135. +PRE_UNINSTALL = :
  136. +POST_UNINSTALL = :
  137. +host_alias =
  138. +host_triplet = i486-pc-linux-gnu
  139. +AMTAR = ${SHELL} /build/buildd/lirc-0.8.6/missing --run tar
  140. +AR = ar
  141. +AS = @AS@
  142. +AWK = mawk
  143. +CXX = g++
  144. +CXXCPP = g++ -E
  145. +DEPDIR = .deps
  146. +DLLTOOL = @DLLTOOL@
  147. +ECHO = echo
  148. +EGREP = /bin/grep -E
  149. +EXEEXT =
  150. +F77 =
  151. +GCJ = @GCJ@
  152. +GCJFLAGS = @GCJFLAGS@
  153. +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
  154. +LIBTOOL = $(SHELL) $(top_builddir)/libtool
  155. +LIBUSB_CONFIG = /usr/bin/libusb-config
  156. +LN_S = ln -s
  157. +OBJDUMP = @OBJDUMP@
  158. +OBJEXT = o
  159. +PACKAGE = lirc
  160. +PYTHON = /usr/bin/python
  161. +PYTHON_EXEC_PREFIX = ${exec_prefix}
  162. +PYTHON_PLATFORM = linux2
  163. +PYTHON_PREFIX = ${prefix}
  164. +PYTHON_VERSION = 2.6
  165. +RANLIB = ranlib
  166. +RC = @RC@
  167. +STRIP = strip
  168. +VERSION = 0.8.6
  169. +X_CFLAGS =
  170. +X_EXTRA_LIBS =
  171. +X_LIBS =
  172. +X_PRE_LIBS = -lSM -lICE
  173. +ac_pkss_mktemp = yes
  174. +am__include = include
  175. +am__quote =
  176. +daemon =
  177. +depmod = /sbin/depmod
  178. +devdir = /dev
  179. +driver = userspace
  180. +forkpty = -lutil
  181. +hw_module = hw_accent.o hw_alsa_usb.o hw_atilibusb.o hw_audio_alsa.o hw_awlibusb.o hw_bte.o hw_commandir.o hw_creative.o hw_creative_infracd.o hw_default.o hw_devinput.o hw_dsp.o hw_ea65.o hw_ftdi.o hw_hiddev.o hw_i2cuser.o hw_irlink.o hw_irman.o hw_livedrive_common.o hw_livedrive_midi.o hw_livedrive_seq.o hw_logitech.o hw_mouseremote.o hw_mp3anywhere.o hw_mplay.o hw_pcmak.o hw_pinsys.o hw_pixelview.o hw_silitek.o hw_tira.o hw_udp.o hw_uirt2.o hw_uirt2_common.o hw_uirt2_raw.o hw_usbx.o receive.o serial.o transmit.o
  182. +hw_module_libs = -lasound -L/usr/lib -lusb -L/usr/lib -lusb -L/usr/lib -lusb -lftdi -lirman
  183. +install_sh = /build/buildd/lirc-0.8.6/install-sh
  184. +irtty =
  185. +kerneldir = missing
  186. +kernelext = ko
  187. +lirc_driver =
  188. +lirc_major = 61
  189. +lircd_conf =
  190. +lircmd_conf =
  191. +maintmode_daemons_extra =
  192. +mkfifo = /usr/bin/mkfifo
  193. +mknod = /bin/mknod
  194. +moduledir = /lib/modules/2.6.24-23-server/misc
  195. +pkgpyexecdir = ${pyexecdir}/lirc
  196. +pkgpythondir = ${pythondir}/lirc
  197. +pyexecdir = ${exec_prefix}/lib/python2.6/site-packages
  198. +pythondir = ${prefix}/lib/python2.6/site-packages
  199. +receive =
  200. +varrundir = /var/run
  201. +vga_progs =
  202. +x_progs = irxevent xmode2
  203. +
  204. +EXTRA_PROGRAMS = automake_dummy
  205. +automake_dummy_SOURCES = lirc_zilog.c
  206. +
  207. +module_DATA = lirc_zilog.o
  208. +
  209. +
  210. +LIRC_DEVDIR = $(PWD)
  211. +
  212. +# some magic for using linux kernel settings
  213. +# when compiling module(s)
  214. +KBUILD_VERBOSE = 1
  215. +LIRC_EXTRA_CFLAGS = -DIRCTL_DEV_MAJOR=$(lirc_major) -DEXPORT_SYMTAB $(DEFS) \
  216. + $(DEFAULT_INCLUDES) -I$(LIRC_DEVDIR)/$(srcdir) -I$(LIRC_DEVDIR)/$(builddir) \
  217. + -I$(LIRC_DEVDIR)/$(top_srcdir) -I$(LIRC_DEVDIR)/$(top_builddir) \
  218. + -I$(KERNEL_LOCATION)/include/ \
  219. + -I$(KERNEL_LOCATION)/drivers/media/video/
  220. +
  221. +
  222. +CLEANFILES = $(module_DATA) .$(module_DATA).flags $(module_DATA:.o=.mod.c) $(module_DATA:.o=.ko) *~
  223. +subdir = drivers/lirc_zilog
  224. +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
  225. +CONFIG_HEADER = $(top_builddir)/config.h
  226. +CONFIG_CLEAN_FILES =
  227. +EXTRA_PROGRAMS = automake_dummy$(EXEEXT)
  228. +am_automake_dummy_OBJECTS = lirc_zilog.$(OBJEXT)
  229. +automake_dummy_OBJECTS = $(am_automake_dummy_OBJECTS)
  230. +automake_dummy_LDADD = $(LDADD)
  231. +automake_dummy_DEPENDENCIES =
  232. +automake_dummy_LDFLAGS =
  233. +
  234. +DEFS = -DHAVE_CONFIG_H
  235. +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
  236. +CPPFLAGS =
  237. +LDFLAGS = -Wl,-Bsymbolic-functions
  238. +LIBS =
  239. +depcomp = $(SHELL) $(top_srcdir)/depcomp
  240. +DEP_FILES = $(DEPDIR)/lirc_zilog.Po
  241. +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
  242. + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  243. +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
  244. + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  245. +CCLD = $(CC)
  246. +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
  247. + $(AM_LDFLAGS) $(LDFLAGS) -o $@
  248. +CFLAGS = -g -O2
  249. +DIST_SOURCES = $(automake_dummy_SOURCES)
  250. +DATA = $(module_DATA)
  251. +
  252. +DIST_COMMON = Makefile.am Makefile.in
  253. +SOURCES = $(automake_dummy_SOURCES)
  254. +
  255. +all: all-am
  256. +
  257. +.SUFFIXES:
  258. +.SUFFIXES: .c .lo .o .obj
  259. +
  260. +mostlyclean-libtool:
  261. + -rm -f *.lo
  262. +
  263. +clean-libtool:
  264. + -rm -rf .libs _libs
  265. +
  266. +distclean-libtool:
  267. + -rm -f libtool
  268. +$(srcdir)/Makefile.in: Makefile.am $(srcdir)/../Makefile.common $(top_srcdir)/configure.ac $(ACLOCAL_M4)
  269. + cd $(top_srcdir) && \
  270. + $(AUTOMAKE) --gnu drivers/lirc_zilog/Makefile
  271. +Makefile:
  272. + cd $(top_builddir) && \
  273. + CONFIG_HEADERS= CONFIG_LINKS= \
  274. + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
  275. +automake_dummy$(EXEEXT): $(automake_dummy_OBJECTS) $(automake_dummy_DEPENDENCIES)
  276. + @rm -f automake_dummy$(EXEEXT)
  277. + $(LINK) $(automake_dummy_LDFLAGS) $(automake_dummy_OBJECTS) $(automake_dummy_LDADD) $(LIBS)
  278. +
  279. +mostlyclean-compile:
  280. + -rm -f *.$(OBJEXT) core *.core
  281. +
  282. +distclean-compile:
  283. + -rm -f *.tab.c
  284. +
  285. +include $(DEPDIR)/lirc_zilog.Po
  286. +
  287. +distclean-depend:
  288. + -rm -rf $(DEPDIR)
  289. +
  290. +.c.o:
  291. + source='$<' object='$@' libtool=no \
  292. + depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \
  293. + $(CCDEPMODE) $(depcomp) \
  294. + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$<
  295. +
  296. +.c.obj:
  297. + source='$<' object='$@' libtool=no \
  298. + depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \
  299. + $(CCDEPMODE) $(depcomp) \
  300. + $(COMPILE) -c `cygpath -w $<`
  301. +
  302. +.c.lo:
  303. + source='$<' object='$@' libtool=yes \
  304. + depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' \
  305. + $(CCDEPMODE) $(depcomp) \
  306. + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
  307. +CCDEPMODE = depmode=gcc3
  308. +uninstall-info-am:
  309. +
  310. +tags: TAGS
  311. +
  312. +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  313. + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
  314. + unique=`for i in $$list; do \
  315. + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  316. + done | \
  317. + $(AWK) ' { files[$$0] = 1; } \
  318. + END { for (i in files) print i; }'`; \
  319. + mkid -fID $$unique $(LISP)
  320. +
  321. +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
  322. + $(TAGS_FILES) $(LISP)
  323. + tags=; \
  324. + here=`pwd`; \
  325. + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
  326. + unique=`for i in $$list; do \
  327. + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  328. + done | \
  329. + $(AWK) ' { files[$$0] = 1; } \
  330. + END { for (i in files) print i; }'`; \
  331. + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
  332. + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP)
  333. +
  334. +GTAGS:
  335. + here=`CDPATH=: && cd $(top_builddir) && pwd` \
  336. + && cd $(top_srcdir) \
  337. + && gtags -i $(GTAGS_ARGS) $$here
  338. +
  339. +distclean-tags:
  340. + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
  341. +
  342. +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
  343. +
  344. +top_distdir = ../..
  345. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
  346. +
  347. +distdir: $(DISTFILES)
  348. + @for file in $(DISTFILES); do \
  349. + if test -f $$file; then d=.; else d=$(srcdir); fi; \
  350. + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
  351. + if test "$$dir" != "$$file" && test "$$dir" != "."; then \
  352. + $(mkinstalldirs) "$(distdir)/$$dir"; \
  353. + fi; \
  354. + if test -d $$d/$$file; then \
  355. + cp -pR $$d/$$file $(distdir) \
  356. + || exit 1; \
  357. + else \
  358. + test -f $(distdir)/$$file \
  359. + || cp -p $$d/$$file $(distdir)/$$file \
  360. + || exit 1; \
  361. + fi; \
  362. + done
  363. +check-am: all-am
  364. +check: check-am
  365. +all-am: Makefile $(DATA)
  366. +
  367. +installdirs:
  368. + $(mkinstalldirs) $(DESTDIR)$(moduledir)
  369. +
  370. +install: install-am
  371. +install-exec: install-exec-am
  372. +install-data: install-data-am
  373. +uninstall: uninstall-am
  374. +
  375. +install-am: all-am
  376. + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
  377. +
  378. +installcheck: installcheck-am
  379. +install-strip:
  380. + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
  381. + `test -z '$(STRIP)' || \
  382. + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
  383. +mostlyclean-generic:
  384. +
  385. +clean-generic:
  386. + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
  387. +
  388. +distclean-generic:
  389. + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
  390. +
  391. +maintainer-clean-generic:
  392. + @echo "This command is intended for maintainers to use"
  393. + @echo "it deletes files that may require special tools to rebuild."
  394. +clean: clean-am
  395. +
  396. +clean-am: clean-generic clean-libtool mostlyclean-am
  397. +
  398. +distclean: distclean-am
  399. +
  400. +distclean-am: clean-am distclean-compile distclean-depend \
  401. + distclean-generic distclean-libtool distclean-tags
  402. +
  403. +dvi: dvi-am
  404. +
  405. +dvi-am:
  406. +
  407. +info: info-am
  408. +
  409. +info-am:
  410. +
  411. +install-data-am: install-data-local install-moduleDATA
  412. +
  413. +install-exec-am: install-exec-local
  414. +
  415. +install-info: install-info-am
  416. +
  417. +install-man:
  418. +
  419. +installcheck-am:
  420. +
  421. +maintainer-clean: maintainer-clean-am
  422. +
  423. +maintainer-clean-am: distclean-am maintainer-clean-generic
  424. +
  425. +mostlyclean: mostlyclean-am
  426. +
  427. +mostlyclean-am: mostlyclean-compile mostlyclean-generic \
  428. + mostlyclean-libtool
  429. +
  430. +uninstall-am: uninstall-info-am uninstall-local uninstall-moduleDATA
  431. +
  432. +.PHONY: GTAGS all all-am check check-am clean clean-generic \
  433. + clean-libtool distclean distclean-compile distclean-depend \
  434. + distclean-generic distclean-libtool distclean-tags distdir dvi \
  435. + dvi-am info info-am install install-am install-data \
  436. + install-data-am install-data-local install-exec install-exec-am \
  437. + install-exec-local install-info install-info-am install-man \
  438. + install-moduleDATA install-strip installcheck installcheck-am \
  439. + installdirs maintainer-clean maintainer-clean-generic \
  440. + mostlyclean mostlyclean-compile mostlyclean-generic \
  441. + mostlyclean-libtool tags uninstall uninstall-am \
  442. + uninstall-info-am uninstall-local uninstall-moduleDATA
  443. +
  444. +export LIRC_EXTRA_CFLAGS KERNEL_LOCATION module_DATA
  445. +
  446. +$(module_DATA): $(automake_dummy_SOURCES) $(top_builddir)/config.h ../lirc.h
  447. + @if test "$(srcdir)" != "$(builddir)" ; then \
  448. + for f in $(automake_dummy_SOURCES) ; do \
  449. + [ -e $$f ] || ln -s $(srcdir)/$$f $$f || exit $$? ; \
  450. + done \
  451. + fi
  452. + -cp $(srcdir)/../lirc_dev/Module*.symvers .
  453. + mv Makefile Makefile.automake
  454. + cp $(srcdir)/../Makefile.kernel Makefile
  455. + CPPFLAGS="" CFLAGS="" LDFLAGS="" \
  456. + $(MAKE) -C $(KERNEL_LOCATION) SUBDIRS=$(LIRC_DEVDIR) modules \
  457. + KBUILD_VERBOSE=$(KBUILD_VERBOSE)
  458. + mv Makefile.automake Makefile
  459. +
  460. +install-moduleDATA: $(module_DATA)
  461. + $(mkinstalldirs) $(DESTDIR)$(moduledir)
  462. + @list='$(module_DATA:.o=.ko)'; for p in $$list; do \
  463. + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
  464. + f="`echo $$p | sed -e 's|^.*/||'`"; \
  465. + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(moduledir)/$$f"; \
  466. + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(moduledir)/$$f; \
  467. + done
  468. +
  469. +uninstall-moduleDATA:
  470. + @list='$(module_DATA:.o=.ko)'; for p in $$list; do \
  471. + f="`echo $$p | sed -e 's|^.*/||'`"; \
  472. + echo " rm -f $(DESTDIR)$(moduledir)/$$f"; \
  473. + rm -f $(DESTDIR)$(moduledir)/$$f; \
  474. + done
  475. +
  476. +#install-exec-local: mkdev
  477. +#uninstall-local: rmdev
  478. +
  479. +mkdev:
  480. + test -e $(DESTDIR)$(devdir)/lirc || ($(mkinstalldirs) $(DESTDIR)$(devdir) && /bin/mknod $(DESTDIR)$(devdir)/lirc c 61 0)
  481. +
  482. +rmdev:
  483. + -test -c $(DESTDIR)$(devdir)/lirc && $(RM) $(DESTDIR)$(devdir)/lirc
  484. +
  485. +#install-data-local: install-moduleDATA
  486. +# -/sbin/depmod -a
  487. +# Tell versions [3.59,3.63) of GNU make to not export all variables.
  488. +# Otherwise a system limit (for SysV at least) may be exceeded.
  489. +.NOEXPORT:
  490. Index: lirc-0.8.6/drivers/lirc_zilog/lirc_zilog.c
  491. ===================================================================
  492. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  493. +++ lirc-0.8.6/drivers/lirc_zilog/lirc_zilog.c 2010-02-21 15:23:08.108913853 -0500
  494. -0,0 +1,1404 @@
  495. +/*
  496. + * i2c IR lirc driver for devices with zilog IR processors
  497. + *
  498. + * Copyright (c) 2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
  499. + * modified for PixelView (BT878P+W/FM) by
  500. + * Michal Kochanowicz <mkochano@pld.org.pl>
  501. + * Christoph Bartelmus <lirc@bartelmus.de>
  502. + * modified for KNC ONE TV Station/Anubis Typhoon TView Tuner by
  503. + * Ulrich Mueller <ulrich.mueller42@web.de>
  504. + * modified for Asus TV-Box and Creative/VisionTek BreakOut-Box by
  505. + * Stefan Jahn <stefan@lkcc.org>
  506. + * modified for inclusion into kernel sources by
  507. + * Jerome Brock <jbrock@users.sourceforge.net>
  508. + * modified for Leadtek Winfast PVR2000 by
  509. + * Thomas Reitmayr (treitmayr@yahoo.com)
  510. + * modified for Hauppauge PVR-150 IR TX device by
  511. + * Mark Weaver <mark@npsl.co.uk>
  512. + * changed name from lirc_pvr150 to lirc_zilog, works on more than pvr-150
  513. + * Jarod Wilson <jarod@redhat.com>
  514. + *
  515. + * parts are cut&pasted from the lirc_i2c.c driver
  516. + *
  517. + * This program is free software; you can redistribute it and/or modify
  518. + * it under the terms of the GNU General Public License as published by
  519. + * the Free Software Foundation; either version 2 of the License, or
  520. + * (at your option) any later version.
  521. + *
  522. + * This program is distributed in the hope that it will be useful,
  523. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  524. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  525. + * GNU General Public License for more details.
  526. + *
  527. + * You should have received a copy of the GNU General Public License
  528. + * along with this program; if not, write to the Free Software
  529. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  530. + *
  531. + */
  532. +
  533. +#include <linux/version.h>
  534. +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 5)
  535. +#error "*******************************************************"
  536. +#error "Sorry, this driver needs kernel version 2.6.5 or higher"
  537. +#error "*******************************************************"
  538. +#endif
  539. +#include <linux/autoconf.h>
  540. +#include <linux/kernel.h>
  541. +#include <linux/errno.h>
  542. +#include <linux/init.h>
  543. +#include <linux/slab.h>
  544. +#include <linux/module.h>
  545. +#include <linux/vmalloc.h>
  546. +#include <linux/kmod.h>
  547. +#include <linux/smp_lock.h>
  548. +#include <linux/completion.h>
  549. +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
  550. +#include <asm/uaccess.h>
  551. +#else
  552. +#include <linux/uaccess.h>
  553. +#endif
  554. +#include <linux/usb.h>
  555. +#include <linux/wait.h>
  556. +#include <linux/time.h>
  557. +#include <linux/firmware.h>
  558. +#include <linux/poll.h>
  559. +#include <linux/kthread.h>
  560. +
  561. +#include "drivers/lirc.h"
  562. +#include "drivers/kcompat.h"
  563. +#include "drivers/lirc_dev/lirc_dev.h"
  564. +
  565. +struct IR {
  566. + struct lirc_driver l;
  567. +
  568. + /* Device info */
  569. + struct mutex lock;
  570. + int open;
  571. +
  572. + /* RX device */
  573. + struct i2c_client c_rx;
  574. + int have_rx;
  575. +
  576. + /* RX device buffer & lock */
  577. + struct lirc_buffer buf;
  578. + struct mutex buf_lock;
  579. +
  580. + /* RX polling thread data */
  581. + struct completion *t_notify;
  582. + struct completion *t_notify2;
  583. + int shutdown;
  584. + struct task_struct *task;
  585. +
  586. + /* RX read data */
  587. + unsigned char b[3];
  588. +
  589. + /* TX device */
  590. + struct i2c_client c_tx;
  591. + int need_boot;
  592. + int have_tx;
  593. +};
  594. +
  595. +/* Minor -> data mapping */
  596. +static struct IR *ir_devices[MAX_IRCTL_DEVICES];
  597. +
  598. +/* Block size for IR transmitter */
  599. +#define TX_BLOCK_SIZE 99
  600. +
  601. +/* Hauppauge IR transmitter data */
  602. +struct tx_data_struct {
  603. + /* Boot block */
  604. + unsigned char *boot_data;
  605. +
  606. + /* Start of binary data block */
  607. + unsigned char *datap;
  608. +
  609. + /* End of binary data block */
  610. + unsigned char *endp;
  611. +
  612. + /* Number of installed codesets */
  613. + unsigned int num_code_sets;
  614. +
  615. + /* Pointers to codesets */
  616. + unsigned char **code_sets;
  617. +
  618. + /* Global fixed data template */
  619. + int fixed[TX_BLOCK_SIZE];
  620. +};
  621. +
  622. +static struct tx_data_struct *tx_data;
  623. +static struct mutex tx_data_lock;
  624. +
  625. +#define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \
  626. + ## args)
  627. +#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
  628. +
  629. +#define ZILOG_HAUPPAUGE_IR_RX_NAME "Zilog/Hauppauge IR RX"
  630. +#define ZILOG_HAUPPAUGE_IR_TX_NAME "Zilog/Hauppauge IR TX"
  631. +
  632. +/* module parameters */
  633. +static int debug; /* debug output */
  634. +static int disable_rx; /* disable RX device */
  635. +static int disable_tx; /* disable TX device */
  636. +static int minor = -1; /* minor number */
  637. +
  638. +#define dprintk(fmt, args...) \
  639. + do { \
  640. + if (debug) \
  641. + printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \
  642. + ## args); \
  643. + } while (0)
  644. +
  645. +static int add_to_buf(struct IR *ir)
  646. +{
  647. + __u16 code;
  648. + unsigned char codes[2];
  649. + unsigned char keybuf[6];
  650. + int got_data = 0;
  651. + int ret;
  652. + int failures = 0;
  653. + unsigned char sendbuf[1] = { 0 };
  654. +
  655. + if (lirc_buffer_full(&ir->buf)) {
  656. + dprintk("buffer overflow\n");
  657. + return -EOVERFLOW;
  658. + }
  659. +
  660. + /*
  661. + * service the device as long as it is returning
  662. + * data and we have space
  663. + */
  664. + do {
  665. + /*
  666. + * Lock i2c bus for the duration. RX/TX chips interfere so
  667. + * this is worth it
  668. + */
  669. + mutex_lock(&ir->lock);
  670. +
  671. + /*
  672. + * Send random "poll command" (?) Windows driver does this
  673. + * and it is a good point to detect chip failure.
  674. + */
  675. + ret = i2c_master_send(&ir->c_rx, sendbuf, 1);
  676. + if (ret != 1) {
  677. + zilog_error("i2c_master_send failed with %d\n", ret);
  678. + if (failures >= 3) {
  679. + mutex_unlock(&ir->lock);
  680. + zilog_error("unable to read from the IR chip "
  681. + "after 3 resets, giving up\n");
  682. + return ret;
  683. + }
  684. +
  685. + /* Looks like the chip crashed, reset it */
  686. + zilog_error("polling the IR receiver chip failed, "
  687. + "trying reset\n");
  688. +
  689. + set_current_state(TASK_UNINTERRUPTIBLE);
  690. + schedule_timeout((100 * HZ + 999) / 1000);
  691. + ir->need_boot = 1;
  692. +
  693. + ++failures;
  694. + mutex_unlock(&ir->lock);
  695. + continue;
  696. + }
  697. +
  698. + ret = i2c_master_recv(&ir->c_rx, keybuf, sizeof(keybuf));
  699. + mutex_unlock(&ir->lock);
  700. + if (ret != sizeof(keybuf)) {
  701. + zilog_error("i2c_master_recv failed with %d -- "
  702. + "keeping last read buffer\n", ret);
  703. + } else {
  704. + ir->b[0] = keybuf[3];
  705. + ir->b[1] = keybuf[4];
  706. + ir->b[2] = keybuf[5];
  707. + dprintk("key (0x%02x/0x%02x)\n", ir->b[0], ir->b[1]);
  708. + }
  709. +
  710. + /* key pressed ? */
  711. +#ifdef I2C_HW_B_HDPVR
  712. + if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR) {
  713. + if (got_data && (keybuf[0] == 0x80))
  714. + return 0;
  715. + else if (got_data && (keybuf[0] == 0x00))
  716. + return -ENODATA;
  717. + } else if ((ir->b[0] & 0x80) == 0)
  718. +#else
  719. + if ((ir->b[0] & 0x80) == 0)
  720. +#endif
  721. + return got_data ? 0 : -ENODATA;
  722. +
  723. + /* look what we have */
  724. + code = (((__u16)ir->b[0] & 0x7f) << 6) | (ir->b[1] >> 2);
  725. +
  726. + codes[0] = (code >> 8) & 0xff;
  727. + codes[1] = code & 0xff;
  728. +
  729. + /* return it */
  730. + lirc_buffer_write(&ir->buf, codes);
  731. + ++got_data;
  732. + } while (!lirc_buffer_full(&ir->buf));
  733. +
  734. + return 0;
  735. +}
  736. +
  737. +/*
  738. + * Main function of the polling thread -- from lirc_dev.
  739. + * We don't fit the LIRC model at all anymore. This is horrible, but
  740. + * basically we have a single RX/TX device with a nasty failure mode
  741. + * that needs to be accounted for across the pair. lirc lets us provide
  742. + * fops, but prevents us from using the internal polling, etc. if we do
  743. + * so. Hence the replication. Might be neater to extend the LIRC model
  744. + * to account for this but I'd think it's a very special case of seriously
  745. + * messed up hardware.
  746. + */
  747. +static int lirc_thread(void *arg)
  748. +{
  749. + struct IR *ir = arg;
  750. +
  751. + if (ir->t_notify != NULL)
  752. + complete(ir->t_notify);
  753. +
  754. + dprintk("poll thread started\n");
  755. +
  756. + do {
  757. + if (ir->open) {
  758. + set_current_state(TASK_INTERRUPTIBLE);
  759. +
  760. + /*
  761. + * This is ~113*2 + 24 + jitter (2*repeat gap +
  762. + * code length). We use this interval as the chip
  763. + * resets every time you poll it (bad!). This is
  764. + * therefore just sufficient to catch all of the
  765. + * button presses. It makes the remote much more
  766. + * responsive. You can see the difference by
  767. + * running irw and holding down a button. With
  768. + * 100ms, the old polling interval, you'll notice
  769. + * breaks in the repeat sequence corresponding to
  770. + * lost keypresses.
  771. + */
  772. + schedule_timeout((260 * HZ) / 1000);
  773. + if (ir->shutdown)
  774. + break;
  775. + if (!add_to_buf(ir))
  776. + wake_up_interruptible(&ir->buf.wait_poll);
  777. + } else {
  778. + /* if device not opened so we can sleep half a second */
  779. + set_current_state(TASK_INTERRUPTIBLE);
  780. + schedule_timeout(HZ/2);
  781. + }
  782. + } while (!ir->shutdown);
  783. +
  784. + if (ir->t_notify2 != NULL)
  785. + wait_for_completion(ir->t_notify2);
  786. +
  787. + ir->task = NULL;
  788. + if (ir->t_notify != NULL)
  789. + complete(ir->t_notify);
  790. +
  791. + dprintk("poll thread ended\n");
  792. + return 0;
  793. +}
  794. +
  795. +static int set_use_inc(void *data)
  796. +{
  797. + struct IR *ir = data;
  798. +
  799. + if (ir->l.owner == NULL || try_module_get(ir->l.owner) == 0)
  800. + return -ENODEV;
  801. +
  802. + /* lock bttv in memory while /dev/lirc is in use */
  803. + /*
  804. + * this is completely broken code. lirc_unregister_driver()
  805. + * must be possible even when the device is open
  806. + */
  807. + if (ir->c_rx.addr)
  808. + i2c_use_client(&ir->c_rx);
  809. + if (ir->c_tx.addr)
  810. + i2c_use_client(&ir->c_tx);
  811. +
  812. + return 0;
  813. +}
  814. +
  815. +static void set_use_dec(void *data)
  816. +{
  817. + struct IR *ir = data;
  818. +
  819. + if (ir->c_rx.addr)
  820. + i2c_release_client(&ir->c_rx);
  821. + if (ir->c_tx.addr)
  822. + i2c_release_client(&ir->c_tx);
  823. + if (ir->l.owner != NULL)
  824. + module_put(ir->l.owner);
  825. +}
  826. +
  827. +/* safe read of a uint32 (always network byte order) */
  828. +static int read_uint32(unsigned char **data,
  829. + unsigned char *endp, unsigned int *val)
  830. +{
  831. + if (*data + 4 > endp)
  832. + return 0;
  833. + *val = ((*data)[0] << 24) | ((*data)[1] << 16) |
  834. + ((*data)[2] << 8) | (*data)[3];
  835. + *data += 4;
  836. + return 1;
  837. +}
  838. +
  839. +/* safe read of a uint8 */
  840. +static int read_uint8(unsigned char **data,
  841. + unsigned char *endp, unsigned char *val)
  842. +{
  843. + if (*data + 1 > endp)
  844. + return 0;
  845. + *val = *((*data)++);
  846. + return 1;
  847. +}
  848. +
  849. +/* safe skipping of N bytes */
  850. +static int skip(unsigned char **data,
  851. + unsigned char *endp, unsigned int distance)
  852. +{
  853. + if (*data + distance > endp)
  854. + return 0;
  855. + *data += distance;
  856. + return 1;
  857. +}
  858. +
  859. +/* decompress key data into the given buffer */
  860. +static int get_key_data(unsigned char *buf,
  861. + unsigned int codeset, unsigned int key)
  862. +{
  863. + unsigned char *data, *endp, *diffs, *key_block;
  864. + unsigned char keys, ndiffs, id;
  865. + unsigned int base, lim, pos, i;
  866. +
  867. + /* Binary search for the codeset */
  868. + for (base = 0, lim = tx_data->num_code_sets; lim; lim >>= 1) {
  869. + pos = base + (lim >> 1);
  870. + data = tx_data->code_sets[pos];
  871. +
  872. + if (!read_uint32(&data, tx_data->endp, &i))
  873. + goto corrupt;
  874. +
  875. + if (i == codeset)
  876. + break;
  877. + else if (codeset > i) {
  878. + base = pos + 1;
  879. + --lim;
  880. + }
  881. + }
  882. + /* Not found? */
  883. + if (!lim)
  884. + return -EPROTO;
  885. +
  886. + /* Set end of data block */
  887. + endp = pos < tx_data->num_code_sets - 1 ?
  888. + tx_data->code_sets[pos + 1] : tx_data->endp;
  889. +
  890. + /* Read the block header */
  891. + if (!read_uint8(&data, endp, &keys) ||
  892. + !read_uint8(&data, endp, &ndiffs) ||
  893. + ndiffs > TX_BLOCK_SIZE || keys == 0)
  894. + goto corrupt;
  895. +
  896. + /* Save diffs & skip */
  897. + diffs = data;
  898. + if (!skip(&data, endp, ndiffs))
  899. + goto corrupt;
  900. +
  901. + /* Read the id of the first key */
  902. + if (!read_uint8(&data, endp, &id))
  903. + goto corrupt;
  904. +
  905. + /* Unpack the first key's data */
  906. + for (i = 0; i < TX_BLOCK_SIZE; ++i) {
  907. + if (tx_data->fixed[i] == -1) {
  908. + if (!read_uint8(&data, endp, &buf[i]))
  909. + goto corrupt;
  910. + } else {
  911. + buf[i] = (unsigned char)tx_data->fixed[i];
  912. + }
  913. + }
  914. +
  915. + /* Early out key found/not found */
  916. + if (key == id)
  917. + return 0;
  918. + if (keys == 1)
  919. + return -EPROTO;
  920. +
  921. + /* Sanity check */
  922. + key_block = data;
  923. + if (!skip(&data, endp, (keys - 1) * (ndiffs + 1)))
  924. + goto corrupt;
  925. +
  926. + /* Binary search for the key */
  927. + for (base = 0, lim = keys - 1; lim; lim >>= 1) {
  928. + /* Seek to block */
  929. + unsigned char *key_data;
  930. + pos = base + (lim >> 1);
  931. + key_data = key_block + (ndiffs + 1) * pos;
  932. +
  933. + if (*key_data == key) {
  934. + /* skip key id */
  935. + ++key_data;
  936. +
  937. + /* found, so unpack the diffs */
  938. + for (i = 0; i < ndiffs; ++i) {
  939. + unsigned char val;
  940. + if (!read_uint8(&key_data, endp, &val) ||
  941. + diffs[i] >= TX_BLOCK_SIZE)
  942. + goto corrupt;
  943. + buf[diffs[i]] = val;
  944. + }
  945. +
  946. + return 0;
  947. + } else if (key > *key_data) {
  948. + base = pos + 1;
  949. + --lim;
  950. + }
  951. + }
  952. + /* Key not found */
  953. + return -EPROTO;
  954. +
  955. +corrupt:
  956. + zilog_error("firmware is corrupt\n");
  957. + return -EFAULT;
  958. +}
  959. +
  960. +/* send a block of data to the IR TX device */
  961. +static int send_data_block(struct IR *ir, unsigned char *data_block)
  962. +{
  963. + int i, j, ret;
  964. + unsigned char buf[5];
  965. +
  966. + for (i = 0; i < TX_BLOCK_SIZE;) {
  967. + int tosend = TX_BLOCK_SIZE - i;
  968. + if (tosend > 4)
  969. + tosend = 4;
  970. + buf[0] = (unsigned char)(i + 1);
  971. + for (j = 0; j < tosend; ++j)
  972. + buf[1 + j] = data_block[i + j];
  973. + dprintk("%02x %02x %02x %02x %02x",
  974. + buf[0], buf[1], buf[2], buf[3], buf[4]);
  975. + ret = i2c_master_send(&ir->c_tx, buf, tosend + 1);
  976. + if (ret != tosend + 1) {
  977. + zilog_error("i2c_master_send failed with %d\n", ret);
  978. + return ret < 0 ? ret : -EFAULT;
  979. + }
  980. + i += tosend;
  981. + }
  982. + return 0;
  983. +}
  984. +
  985. +/* send boot data to the IR TX device */
  986. +static int send_boot_data(struct IR *ir)
  987. +{
  988. + int ret;
  989. + unsigned char buf[4];
  990. +
  991. + /* send the boot block */
  992. + ret = send_data_block(ir, tx_data->boot_data);
  993. + if (ret != 0)
  994. + return ret;
  995. +
  996. + /* kick it off? */
  997. + buf[0] = 0x00;
  998. + buf[1] = 0x20;
  999. + ret = i2c_master_send(&ir->c_tx, buf, 2);
  1000. + if (ret != 2) {
  1001. + zilog_error("i2c_master_send failed with %d\n", ret);
  1002. + return ret < 0 ? ret : -EFAULT;
  1003. + }
  1004. + ret = i2c_master_send(&ir->c_tx, buf, 1);
  1005. + if (ret != 1) {
  1006. + zilog_error("i2c_master_send failed with %d\n", ret);
  1007. + return ret < 0 ? ret : -EFAULT;
  1008. + }
  1009. +
  1010. + /* Here comes the firmware version... (hopefully) */
  1011. + ret = i2c_master_recv(&ir->c_tx, buf, 4);
  1012. + if (ret != 4) {
  1013. + zilog_error("i2c_master_recv failed with %d\n", ret);
  1014. + return 0;
  1015. + }
  1016. + if (buf[0] != 0x80) {
  1017. + zilog_error("unexpected IR TX response: %02x\n", buf[0]);
  1018. + return 0;
  1019. + }
  1020. + zilog_notify("Zilog/Hauppauge IR blaster firmware version "
  1021. + "%d.%d.%d loaded\n", buf[1], buf[2], buf[3]);
  1022. +
  1023. + return 0;
  1024. +}
  1025. +
  1026. +/* unload "firmware", lock held */
  1027. +static void fw_unload_locked(void)
  1028. +{
  1029. + if (tx_data) {
  1030. + if (tx_data->code_sets)
  1031. + vfree(tx_data->code_sets);
  1032. +
  1033. + if (tx_data->datap)
  1034. + vfree(tx_data->datap);
  1035. +
  1036. + vfree(tx_data);
  1037. + tx_data = NULL;
  1038. + dprintk("successfully unloaded IR blaster firmware\n");
  1039. + }
  1040. +}
  1041. +
  1042. +/* unload "firmware" for the IR TX device */
  1043. +static void fw_unload(void)
  1044. +{
  1045. + mutex_lock(&tx_data_lock);
  1046. + fw_unload_locked();
  1047. + mutex_unlock(&tx_data_lock);
  1048. +}
  1049. +
  1050. +/* load "firmware" for the IR TX device */
  1051. +static int fw_load(struct IR *ir)
  1052. +{
  1053. + int ret;
  1054. + unsigned int i;
  1055. + unsigned char *data, version, num_global_fixed;
  1056. + const struct firmware *fw_entry;
  1057. +
  1058. + /* Already loaded? */
  1059. + mutex_lock(&tx_data_lock);
  1060. + if (tx_data) {
  1061. + ret = 0;
  1062. + goto out;
  1063. + }
  1064. +
  1065. + /* Request codeset data file */
  1066. + ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &ir->c_tx.dev);
  1067. + if (ret != 0) {
  1068. + zilog_error("firmware haup-ir-blaster.bin not available "
  1069. + "(%d)\n", ret);
  1070. + ret = ret < 0 ? ret : -EFAULT;
  1071. + goto out;
  1072. + }
  1073. + dprintk("firmware of size %zu loaded\n", fw_entry->size);
  1074. +
  1075. + /* Parse the file */
  1076. + tx_data = vmalloc(sizeof(*tx_data));
  1077. + if (tx_data == NULL) {
  1078. + zilog_error("out of memory\n");
  1079. + release_firmware(fw_entry);
  1080. + ret = -ENOMEM;
  1081. + goto out;
  1082. + }
  1083. + tx_data->code_sets = NULL;
  1084. +
  1085. + /* Copy the data so hotplug doesn't get confused and timeout */
  1086. + tx_data->datap = vmalloc(fw_entry->size);
  1087. + if (tx_data->datap == NULL) {
  1088. + zilog_error("out of memory\n");
  1089. + release_firmware(fw_entry);
  1090. + vfree(tx_data);
  1091. + ret = -ENOMEM;
  1092. + goto out;
  1093. + }
  1094. + memcpy(tx_data->datap, fw_entry->data, fw_entry->size);
  1095. + tx_data->endp = tx_data->datap + fw_entry->size;
  1096. + release_firmware(fw_entry); fw_entry = NULL;
  1097. +
  1098. + /* Check version */
  1099. + data = tx_data->datap;
  1100. + if (!read_uint8(&data, tx_data->endp, &version))
  1101. + goto corrupt;
  1102. + if (version != 1) {
  1103. + zilog_error("unsupported code set file version (%u, expected"
  1104. + "1) -- please upgrade to a newer driver",
  1105. + version);
  1106. + fw_unload_locked();
  1107. + ret = -EFAULT;
  1108. + goto out;
  1109. + }
  1110. +
  1111. + /* Save boot block for later */
  1112. + tx_data->boot_data = data;
  1113. + if (!skip(&data, tx_data->endp, TX_BLOCK_SIZE))
  1114. + goto corrupt;
  1115. +
  1116. + if (!read_uint32(&data, tx_data->endp,
  1117. + &tx_data->num_code_sets))
  1118. + goto corrupt;
  1119. +
  1120. + dprintk("%u IR blaster codesets loaded\n", tx_data->num_code_sets);
  1121. +
  1122. + tx_data->code_sets = vmalloc(
  1123. + tx_data->num_code_sets * sizeof(char *));
  1124. + if (tx_data->code_sets == NULL) {
  1125. + fw_unload_locked();
  1126. + ret = -ENOMEM;
  1127. + goto out;
  1128. + }
  1129. +
  1130. + for (i = 0; i < TX_BLOCK_SIZE; ++i)
  1131. + tx_data->fixed[i] = -1;
  1132. +
  1133. + /* Read global fixed data template */
  1134. + if (!read_uint8(&data, tx_data->endp, &num_global_fixed) ||
  1135. + num_global_fixed > TX_BLOCK_SIZE)
  1136. + goto corrupt;
  1137. + for (i = 0; i < num_global_fixed; ++i) {
  1138. + unsigned char pos, val;
  1139. + if (!read_uint8(&data, tx_data->endp, &pos) ||
  1140. + !read_uint8(&data, tx_data->endp, &val) ||
  1141. + pos >= TX_BLOCK_SIZE)
  1142. + goto corrupt;
  1143. + tx_data->fixed[pos] = (int)val;
  1144. + }
  1145. +
  1146. + /* Filch out the position of each code set */
  1147. + for (i = 0; i < tx_data->num_code_sets; ++i) {
  1148. + unsigned int id;
  1149. + unsigned char keys;
  1150. + unsigned char ndiffs;
  1151. +
  1152. + /* Save the codeset position */
  1153. + tx_data->code_sets[i] = data;
  1154. +
  1155. + /* Read header */
  1156. + if (!read_uint32(&data, tx_data->endp, &id) ||
  1157. + !read_uint8(&data, tx_data->endp, &keys) ||
  1158. + !read_uint8(&data, tx_data->endp, &ndiffs) ||
  1159. + ndiffs > TX_BLOCK_SIZE || keys == 0)
  1160. + goto corrupt;
  1161. +
  1162. + /* skip diff positions */
  1163. + if (!skip(&data, tx_data->endp, ndiffs))
  1164. + goto corrupt;
  1165. +
  1166. + /*
  1167. + * After the diffs we have the first key id + data -
  1168. + * global fixed
  1169. + */
  1170. + if (!skip(&data, tx_data->endp,
  1171. + 1 + TX_BLOCK_SIZE - num_global_fixed))
  1172. + goto corrupt;
  1173. +
  1174. + /* Then we have keys-1 blocks of key id+diffs */
  1175. + if (!skip(&data, tx_data->endp,
  1176. + (ndiffs + 1) * (keys - 1)))
  1177. + goto corrupt;
  1178. + }
  1179. + ret = 0;
  1180. + goto out;
  1181. +
  1182. +corrupt:
  1183. + zilog_error("firmware is corrupt\n");
  1184. + fw_unload_locked();
  1185. + ret = -EFAULT;
  1186. +
  1187. +out:
  1188. + mutex_unlock(&tx_data_lock);
  1189. + return ret;
  1190. +}
  1191. +
  1192. +/* initialise the IR TX device */
  1193. +static int tx_init(struct IR *ir)
  1194. +{
  1195. + int ret;
  1196. +
  1197. + /* Load 'firmware' */
  1198. + ret = fw_load(ir);
  1199. + if (ret != 0)
  1200. + return ret;
  1201. +
  1202. + /* Send boot block */
  1203. + ret = send_boot_data(ir);
  1204. + if (ret != 0)
  1205. + return ret;
  1206. + ir->need_boot = 0;
  1207. +
  1208. + /* Looks good */
  1209. + return 0;
  1210. +}
  1211. +
  1212. +/* do nothing stub to make LIRC happy */
  1213. +static loff_t lseek(struct file *filep, loff_t offset, int orig)
  1214. +{
  1215. + return -ESPIPE;
  1216. +}
  1217. +
  1218. +/* copied from lirc_dev */
  1219. +static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
  1220. +{
  1221. + struct IR *ir = (struct IR *)filep->private_data;
  1222. + unsigned char buf[ir->buf.chunk_size];
  1223. + int ret = 0, written = 0;
  1224. + DECLARE_WAITQUEUE(wait, current);
  1225. +
  1226. + dprintk("read called\n");
  1227. + if (ir->c_rx.addr == 0)
  1228. + return -ENODEV;
  1229. +
  1230. + if (mutex_lock_interruptible(&ir->buf_lock))
  1231. + return -ERESTARTSYS;
  1232. +
  1233. + if (n % ir->buf.chunk_size) {
  1234. + dprintk("read result = -EINVAL\n");
  1235. + mutex_unlock(&ir->buf_lock);
  1236. + return -EINVAL;
  1237. + }
  1238. +
  1239. + /*
  1240. + * we add ourselves to the task queue before buffer check
  1241. + * to avoid losing scan code (in case when queue is awaken somewhere
  1242. + * between while condition checking and scheduling)
  1243. + */
  1244. + add_wait_queue(&ir->buf.wait_poll, &wait);
  1245. + set_current_state(TASK_INTERRUPTIBLE);
  1246. +
  1247. + /*
  1248. + * while we didn't provide 'length' bytes, device is opened in blocking
  1249. + * mode and 'copy_to_user' is happy, wait for data.
  1250. + */
  1251. + while (written < n && ret == 0) {
  1252. + if (lirc_buffer_empty(&ir->buf)) {
  1253. + /*
  1254. + * According to the read(2) man page, 'written' can be
  1255. + * returned as less than 'n', instead of blocking
  1256. + * again, returning -EWOULDBLOCK, or returning
  1257. + * -ERESTARTSYS
  1258. + */
  1259. + if (written)
  1260. + break;
  1261. + if (filep->f_flags & O_NONBLOCK) {
  1262. + ret = -EWOULDBLOCK;
  1263. + break;
  1264. + }
  1265. + if (signal_pending(current)) {
  1266. + ret = -ERESTARTSYS;
  1267. + break;
  1268. + }
  1269. + schedule();
  1270. + set_current_state(TASK_INTERRUPTIBLE);
  1271. + } else {
  1272. + lirc_buffer_read(&ir->buf, buf);
  1273. + ret = copy_to_user((void *)outbuf+written, buf,
  1274. + ir->buf.chunk_size);
  1275. + written += ir->buf.chunk_size;
  1276. + }
  1277. + }
  1278. +
  1279. + remove_wait_queue(&ir->buf.wait_poll, &wait);
  1280. + set_current_state(TASK_RUNNING);
  1281. + mutex_unlock(&ir->buf_lock);
  1282. +
  1283. + dprintk("read result = %s (%d)\n",
  1284. + ret ? "-EFAULT" : "OK", ret);
  1285. +
  1286. + return ret ? ret : written;
  1287. +}
  1288. +
  1289. +/* send a keypress to the IR TX device */
  1290. +static int send_code(struct IR *ir, unsigned int code, unsigned int key)
  1291. +{
  1292. + unsigned char data_block[TX_BLOCK_SIZE];
  1293. + unsigned char buf[2];
  1294. + int i, ret;
  1295. +
  1296. + /* Get data for the codeset/key */
  1297. + ret = get_key_data(data_block, code, key);
  1298. +
  1299. + if (ret == -EPROTO) {
  1300. + zilog_error("failed to get data for code %u, key %u -- check "
  1301. + "lircd.conf entries\n", code, key);
  1302. + return ret;
  1303. + } else if (ret != 0)
  1304. + return ret;
  1305. +
  1306. + /* Send the data block */
  1307. + ret = send_data_block(ir, data_block);
  1308. + if (ret != 0)
  1309. + return ret;
  1310. +
  1311. + /* Send data block length? */
  1312. + buf[0] = 0x00;
  1313. + buf[1] = 0x40;
  1314. + ret = i2c_master_send(&ir->c_tx, buf, 2);
  1315. + if (ret != 2) {
  1316. + zilog_error("i2c_master_send failed with %d\n", ret);
  1317. + return ret < 0 ? ret : -EFAULT;
  1318. + }
  1319. + ret = i2c_master_send(&ir->c_tx, buf, 1);
  1320. + if (ret != 1) {
  1321. + zilog_error("i2c_master_send failed with %d\n", ret);
  1322. + return ret < 0 ? ret : -EFAULT;
  1323. + }
  1324. +
  1325. + /* Send finished download? */
  1326. + ret = i2c_master_recv(&ir->c_tx, buf, 1);
  1327. + if (ret != 1) {
  1328. + zilog_error("i2c_master_recv failed with %d\n", ret);
  1329. + return ret < 0 ? ret : -EFAULT;
  1330. + }
  1331. + if (buf[0] != 0xA0) {
  1332. + zilog_error("unexpected IR TX response #1: %02x\n",
  1333. + buf[0]);
  1334. + return -EFAULT;
  1335. + }
  1336. +
  1337. + /* Send prepare command? */
  1338. + buf[0] = 0x00;
  1339. + buf[1] = 0x80;
  1340. + ret = i2c_master_send(&ir->c_tx, buf, 2);
  1341. + if (ret != 2) {
  1342. + zilog_error("i2c_master_send failed with %d\n", ret);
  1343. + return ret < 0 ? ret : -EFAULT;
  1344. + }
  1345. +
  1346. +#ifdef I2C_HW_B_HDPVR
  1347. + /*
  1348. + * The sleep bits aren't necessary on the HD PVR, and in fact, the
  1349. + * last i2c_master_recv always fails with a -5, so for now, we're
  1350. + * going to skip this whole mess and say we're done on the HD PVR
  1351. + */
  1352. + if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR)
  1353. + goto done;
  1354. +#endif
  1355. +
  1356. + /*
  1357. + * This bit NAKs until the device is ready, so we retry it
  1358. + * sleeping a bit each time. This seems to be what the windows
  1359. + * driver does, approximately.
  1360. + * Try for up to 1s.
  1361. + */
  1362. + for (i = 0; i < 20; ++i) {
  1363. + set_current_state(TASK_UNINTERRUPTIBLE);
  1364. + schedule_timeout((50 * HZ + 999) / 1000);
  1365. + ret = i2c_master_send(&ir->c_tx, buf, 1);
  1366. + if (ret == 1)
  1367. + break;
  1368. + dprintk("NAK expected: i2c_master_send "
  1369. + "failed with %d (try %d)\n", ret, i+1);
  1370. + }
  1371. + if (ret != 1) {
  1372. + zilog_error("IR TX chip never got ready: last i2c_master_send "
  1373. + "failed with %d\n", ret);
  1374. + return ret < 0 ? ret : -EFAULT;
  1375. + }
  1376. +
  1377. + /* Seems to be an 'ok' response */
  1378. + i = i2c_master_recv(&ir->c_tx, buf, 1);
  1379. + if (i != 1) {
  1380. + zilog_error("i2c_master_recv failed with %d\n", ret);
  1381. + return -EFAULT;
  1382. + }
  1383. + if (buf[0] != 0x80) {
  1384. + zilog_error("unexpected IR TX response #2: %02x\n", buf[0]);
  1385. + return -EFAULT;
  1386. + }
  1387. +
  1388. +done:
  1389. + /* Oh good, it worked */
  1390. + dprintk("sent code %u, key %u\n", code, key);
  1391. + return 0;
  1392. +}
  1393. +
  1394. +/*
  1395. + * Write a code to the device. We take in a 32-bit number (an int) and then
  1396. + * decode this to a codeset/key index. The key data is then decompressed and
  1397. + * sent to the device. We have a spin lock as per i2c documentation to prevent
  1398. + * multiple concurrent sends which would probably cause the device to explode.
  1399. + */
  1400. +static ssize_t write(struct file *filep, const char *buf, size_t n,
  1401. + loff_t *ppos)
  1402. +{
  1403. + struct IR *ir = (struct IR *)filep->private_data;
  1404. + size_t i;
  1405. + int failures = 0;
  1406. +
  1407. + if (ir->c_tx.addr == 0)
  1408. + return -ENODEV;
  1409. +
  1410. + /* Validate user parameters */
  1411. + if (n % sizeof(int))
  1412. + return -EINVAL;
  1413. +
  1414. + /* Lock i2c bus for the duration */
  1415. + mutex_lock(&ir->lock);
  1416. +
  1417. + /* Send each keypress */
  1418. + for (i = 0; i < n;) {
  1419. + int ret = 0;
  1420. + int command;
  1421. +
  1422. + if (copy_from_user(&command, buf + i, sizeof(command))) {
  1423. + mutex_unlock(&ir->lock);
  1424. + return -EFAULT;
  1425. + }
  1426. +
  1427. + /* Send boot data first if required */
  1428. + if (ir->need_boot == 1) {
  1429. + ret = send_boot_data(ir);
  1430. + if (ret == 0)
  1431. + ir->need_boot = 0;
  1432. + }
  1433. +
  1434. + /* Send the code */
  1435. + if (ret == 0) {
  1436. + ret = send_code(ir, (unsigned)command >> 16,
  1437. + (unsigned)command & 0xFFFF);
  1438. + if (ret == -EPROTO) {
  1439. + mutex_unlock(&ir->lock);
  1440. + return ret;
  1441. + }
  1442. + }
  1443. +
  1444. + /*
  1445. + * Hmm, a failure. If we've had a few then give up, otherwise
  1446. + * try a reset
  1447. + */
  1448. + if (ret != 0) {
  1449. + /* Looks like the chip crashed, reset it */
  1450. + zilog_error("sending to the IR transmitter chip "
  1451. + "failed, trying reset\n");
  1452. +
  1453. + if (failures >= 3) {
  1454. + zilog_error("unable to send to the IR chip "
  1455. + "after 3 resets, giving up\n");
  1456. + mutex_unlock(&ir->lock);
  1457. + return ret;
  1458. + }
  1459. + set_current_state(TASK_UNINTERRUPTIBLE);
  1460. + schedule_timeout((100 * HZ + 999) / 1000);
  1461. + ir->need_boot = 1;
  1462. + ++failures;
  1463. + } else
  1464. + i += sizeof(int);
  1465. + }
  1466. +
  1467. + /* Release i2c bus */
  1468. + mutex_unlock(&ir->lock);
  1469. +
  1470. + /* All looks good */
  1471. + return n;
  1472. +}
  1473. +
  1474. +/* copied from lirc_dev */
  1475. +static unsigned int poll(struct file *filep, poll_table *wait)
  1476. +{
  1477. + struct IR *ir = (struct IR *)filep->private_data;
  1478. + unsigned int ret;
  1479. +
  1480. + dprintk("poll called\n");
  1481. + if (ir->c_rx.addr == 0)
  1482. + return -ENODEV;
  1483. +
  1484. + mutex_lock(&ir->buf_lock);
  1485. +
  1486. + poll_wait(filep, &ir->buf.wait_poll, wait);
  1487. +
  1488. + dprintk("poll result = %s\n",
  1489. + lirc_buffer_empty(&ir->buf) ? "0" : "POLLIN|POLLRDNORM");
  1490. +
  1491. + ret = lirc_buffer_empty(&ir->buf) ? 0 : (POLLIN|POLLRDNORM);
  1492. +
  1493. + mutex_unlock(&ir->buf_lock);
  1494. + return ret;
  1495. +}
  1496. +
  1497. +static int ioctl(struct inode *node, struct file *filep, unsigned int cmd,
  1498. + unsigned long arg)
  1499. +{
  1500. + struct IR *ir = (struct IR *)filep->private_data;
  1501. + int result;
  1502. + unsigned long mode, features = 0;
  1503. +
  1504. + if (ir->c_rx.addr != 0)
  1505. + features |= LIRC_CAN_REC_LIRCCODE;
  1506. + if (ir->c_tx.addr != 0)
  1507. + features |= LIRC_CAN_SEND_PULSE;
  1508. +
  1509. + switch (cmd) {
  1510. + case LIRC_GET_LENGTH:
  1511. + result = put_user((unsigned long)13,
  1512. + (unsigned long *)arg);
  1513. + break;
  1514. + case LIRC_GET_FEATURES:
  1515. + result = put_user(features, (unsigned long *) arg);
  1516. + break;
  1517. + case LIRC_GET_REC_MODE:
  1518. + if (!(features&LIRC_CAN_REC_MASK))
  1519. + return -ENOSYS;
  1520. +
  1521. + result = put_user(LIRC_REC2MODE
  1522. + (features&LIRC_CAN_REC_MASK),
  1523. + (unsigned long *)arg);
  1524. + break;
  1525. + case LIRC_SET_REC_MODE:
  1526. + if (!(features&LIRC_CAN_REC_MASK))
  1527. + return -ENOSYS;
  1528. +
  1529. + result = get_user(mode, (unsigned long *)arg);
  1530. + if (!result && !(LIRC_MODE2REC(mode) & features))
  1531. + result = -EINVAL;
  1532. + break;
  1533. + case LIRC_GET_SEND_MODE:
  1534. + if (!(features&LIRC_CAN_SEND_MASK))
  1535. + return -ENOSYS;
  1536. +
  1537. + result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg);
  1538. + break;
  1539. + case LIRC_SET_SEND_MODE:
  1540. + if (!(features&LIRC_CAN_SEND_MASK))
  1541. + return -ENOSYS;
  1542. +
  1543. + result = get_user(mode, (unsigned long *) arg);
  1544. + if (!result && mode != LIRC_MODE_PULSE)
  1545. + return -EINVAL;
  1546. + break;
  1547. + default:
  1548. + return -EINVAL;
  1549. + }
  1550. + return result;
  1551. +}
  1552. +
  1553. +/*
  1554. + * Open the IR device. Get hold of our IR structure and
  1555. + * stash it in private_data for the file
  1556. + */
  1557. +static int open(struct inode *node, struct file *filep)
  1558. +{
  1559. + struct IR *ir;
  1560. + int ret;
  1561. +
  1562. + /* find our IR struct */
  1563. + unsigned minor = MINOR(node->i_rdev);
  1564. + if (minor >= MAX_IRCTL_DEVICES) {
  1565. + dprintk("minor %d: open result = -ENODEV\n",
  1566. + minor);
  1567. + return -ENODEV;
  1568. + }
  1569. + ir = ir_devices[minor];
  1570. +
  1571. + /* increment in use count */
  1572. + mutex_lock(&ir->lock);
  1573. + ++ir->open;
  1574. + ret = set_use_inc(ir);
  1575. + if (ret != 0) {
  1576. + --ir->open;
  1577. + mutex_unlock(&ir->lock);
  1578. + return ret;
  1579. + }
  1580. + mutex_unlock(&ir->lock);
  1581. +
  1582. + /* stash our IR struct */
  1583. + filep->private_data = ir;
  1584. +
  1585. + return 0;
  1586. +}
  1587. +
  1588. +/* Close the IR device */
  1589. +static int close(struct inode *node, struct file *filep)
  1590. +{
  1591. + /* find our IR struct */
  1592. + struct IR *ir = (struct IR *)filep->private_data;
  1593. + if (ir == NULL) {
  1594. + zilog_error("close: no private_data attached to the file!\n");
  1595. + return -ENODEV;
  1596. + }
  1597. +
  1598. + /* decrement in use count */
  1599. + mutex_lock(&ir->lock);
  1600. + --ir->open;
  1601. + set_use_dec(ir);
  1602. + mutex_unlock(&ir->lock);
  1603. +
  1604. + return 0;
  1605. +}
  1606. +
  1607. +static struct lirc_driver lirc_template = {
  1608. + .name = "lirc_zilog",
  1609. + .set_use_inc = set_use_inc,
  1610. + .set_use_dec = set_use_dec,
  1611. + .owner = THIS_MODULE
  1612. +};
  1613. +
  1614. +static int ir_remove(struct i2c_client *client);
  1615. +static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id);
  1616. +static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg);
  1617. +
  1618. +static const struct i2c_device_id ir_transceiver_id[] = {
  1619. + /* Generic entry for any IR transceiver */
  1620. + { "ir_video", 0 },
  1621. + /* IR device specific entries should be added here */
  1622. + { "ir_tx_z8f0811_haup", 0 },
  1623. + { "ir_rx_z8f0811_haup", 0 },
  1624. + { }
  1625. +};
  1626. +
  1627. +static struct i2c_driver driver = {
  1628. + .driver = {
  1629. + .owner = THIS_MODULE,
  1630. + .name = "Zilog/Hauppauge i2c IR",
  1631. + },
  1632. + .probe = ir_probe,
  1633. + .remove = ir_remove,
  1634. + .command = ir_command,
  1635. + .id_table = ir_transceiver_id,
  1636. +};
  1637. +
  1638. +static struct file_operations lirc_fops = {
  1639. + .owner = THIS_MODULE,
  1640. + .llseek = lseek,
  1641. + .read = read,
  1642. + .write = write,
  1643. + .poll = poll,
  1644. + .ioctl = ioctl,
  1645. + .open = open,
  1646. + .release = close
  1647. +};
  1648. +
  1649. +static int ir_remove(struct i2c_client *client)
  1650. +{
  1651. + struct IR *ir = i2c_get_clientdata(client);
  1652. +
  1653. + mutex_lock(&ir->lock);
  1654. +
  1655. + if (ir->have_rx || ir->have_tx) {
  1656. + DECLARE_COMPLETION(tn);
  1657. + DECLARE_COMPLETION(tn2);
  1658. +
  1659. + /* end up polling thread */
  1660. + if (ir->task && !IS_ERR(ir->task)) {
  1661. + ir->t_notify = &tn;
  1662. + ir->t_notify2 = &tn2;
  1663. + ir->shutdown = 1;
  1664. + wake_up_process(ir->task);
  1665. + complete(&tn2);
  1666. + wait_for_completion(&tn);
  1667. + ir->t_notify = NULL;
  1668. + ir->t_notify2 = NULL;
  1669. + }
  1670. +
  1671. + } else {
  1672. + mutex_unlock(&ir->lock);
  1673. + zilog_error("%s: detached from something we didn't "
  1674. + "attach to\n", __func__);
  1675. + return -ENODEV;
  1676. + }
  1677. +
  1678. + /* unregister lirc driver */
  1679. + if (ir->l.minor >= 0 && ir->l.minor < MAX_IRCTL_DEVICES) {
  1680. + lirc_unregister_driver(ir->l.minor);
  1681. + ir_devices[ir->l.minor] = NULL;
  1682. + }
  1683. +
  1684. + /* free memory */
  1685. + lirc_buffer_free(&ir->buf);
  1686. + mutex_unlock(&ir->lock);
  1687. + kfree(ir);
  1688. +
  1689. + return 0;
  1690. +}
  1691. +
  1692. +static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
  1693. +{
  1694. + struct IR *ir = NULL;
  1695. + struct i2c_adapter *adap = client->adapter;
  1696. + char buf;
  1697. + int ret;
  1698. + int have_rx = 0, have_tx = 0;
  1699. +
  1700. + dprintk("%s: adapter id=0x%x, client addr=0x%02x\n",
  1701. + __func__, adap->id, client->addr);
  1702. +
  1703. + /* if this isn't an appropriate device, bail w/-ENODEV now */
  1704. + if (!(adap->id == I2C_HW_B_BT848 ||
  1705. +#ifdef I2C_HW_B_HDPVR
  1706. + adap->id == I2C_HW_B_HDPVR ||
  1707. +#endif
  1708. + adap->id == I2C_HW_B_CX2341X))
  1709. + goto out_nodev;
  1710. +
  1711. + /*
  1712. + * The external IR receiver is at i2c address 0x71.
  1713. + * The IR transmitter is at 0x70.
  1714. + */
  1715. + client->addr = 0x70;
  1716. +
  1717. + if (!disable_tx) {
  1718. + if (i2c_master_recv(client, &buf, 1) == 1)
  1719. + have_tx = 1;
  1720. + dprintk("probe 0x70 @ %s: %s\n",
  1721. + adap->name, have_tx ? "success" : "failed");
  1722. + }
  1723. +
  1724. + if (!disable_rx) {
  1725. + client->addr = 0x71;
  1726. + if (i2c_master_recv(client, &buf, 1) == 1)
  1727. + have_rx = 1;
  1728. + dprintk("probe 0x71 @ %s: %s\n",
  1729. + adap->name, have_rx ? "success" : "failed");
  1730. + }
  1731. +
  1732. + if (!(have_rx || have_tx)) {
  1733. + zilog_error("%s: no devices found\n", adap->name);
  1734. + goto out_nodev;
  1735. + }
  1736. +
  1737. + printk(KERN_INFO "lirc_zilog: chip found with %s\n",
  1738. + have_rx && have_tx ? "RX and TX" :
  1739. + have_rx ? "RX only" : "TX only");
  1740. +
  1741. + ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
  1742. +
  1743. + if (!ir)
  1744. + goto out_nomem;
  1745. +
  1746. + ret = lirc_buffer_init(&ir->buf, 2, BUFLEN / 2);
  1747. + if (ret)
  1748. + goto out_nomem;
  1749. +
  1750. + mutex_init(&ir->lock);
  1751. + mutex_init(&ir->buf_lock);
  1752. + ir->need_boot = 1;
  1753. +
  1754. + memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));
  1755. + ir->l.minor = -1;
  1756. +
  1757. + /* I2C attach to device */
  1758. + i2c_set_clientdata(client, ir);
  1759. +
  1760. + /* initialise RX device */
  1761. + if (have_rx) {
  1762. + DECLARE_COMPLETION(tn);
  1763. + memcpy(&ir->c_rx, client, sizeof(struct i2c_client));
  1764. +
  1765. + ir->c_rx.addr = 0x71;
  1766. + strncpy(ir->c_rx.name, ZILOG_HAUPPAUGE_IR_RX_NAME,
  1767. + I2C_NAME_SIZE);
  1768. +
  1769. + /* try to fire up polling thread */
  1770. + ir->t_notify = &tn;
  1771. + ir->task = kthread_run(lirc_thread, ir, "lirc_zilog");
  1772. + if (IS_ERR(ir->task)) {
  1773. + ret = PTR_ERR(ir->task);
  1774. + zilog_error("lirc_register_driver: cannot run "
  1775. + "poll thread %d\n", ret);
  1776. + goto err;
  1777. + }
  1778. + wait_for_completion(&tn);
  1779. + ir->t_notify = NULL;
  1780. + ir->have_rx = 1;
  1781. + }
  1782. +
  1783. + /* initialise TX device */
  1784. + if (have_tx) {
  1785. + memcpy(&ir->c_tx, client, sizeof(struct i2c_client));
  1786. + ir->c_tx.addr = 0x70;
  1787. + strncpy(ir->c_tx.name, ZILOG_HAUPPAUGE_IR_TX_NAME,
  1788. + I2C_NAME_SIZE);
  1789. + ir->have_tx = 1;
  1790. + }
  1791. +
  1792. + /* set lirc_dev stuff */
  1793. + ir->l.code_length = 13;
  1794. + ir->l.rbuf = &ir->buf;
  1795. + ir->l.fops = &lirc_fops;
  1796. + ir->l.data = ir;
  1797. + ir->l.minor = minor;
  1798. + ir->l.dev = &adap->dev;
  1799. + ir->l.sample_rate = 0;
  1800. +
  1801. + /* register with lirc */
  1802. + ir->l.minor = lirc_register_driver(&ir->l);
  1803. + if (ir->l.minor < 0 || ir->l.minor >= MAX_IRCTL_DEVICES) {
  1804. + zilog_error("ir_attach: \"minor\" must be between 0 and %d "
  1805. + "(%d)!\n", MAX_IRCTL_DEVICES-1, ir->l.minor);
  1806. + ret = -EBADRQC;
  1807. + goto err;
  1808. + }
  1809. +
  1810. + /* store this for getting back in open() later on */
  1811. + ir_devices[ir->l.minor] = ir;
  1812. +
  1813. + /*
  1814. + * if we have the tx device, load the 'firmware'. We do this
  1815. + * after registering with lirc as otherwise hotplug seems to take
  1816. + * 10s to create the lirc device.
  1817. + */
  1818. + if (have_tx) {
  1819. + /* Special TX init */
  1820. + ret = tx_init(ir);
  1821. + if (ret != 0)
  1822. + goto err;
  1823. + }
  1824. +
  1825. + return 0;
  1826. +
  1827. +err:
  1828. + /* undo everything, hopefully... */
  1829. + if (ir->c_rx.addr)
  1830. + ir_remove(&ir->c_rx);
  1831. + if (ir->c_tx.addr)
  1832. + ir_remove(&ir->c_tx);
  1833. + return ret;
  1834. +
  1835. +out_nodev:
  1836. + zilog_error("no device found\n");
  1837. + return -ENODEV;
  1838. +
  1839. +out_nomem:
  1840. + zilog_error("memory allocation failure\n");
  1841. + kfree(ir);
  1842. + return -ENOMEM;
  1843. +}
  1844. +
  1845. +static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg)
  1846. +{
  1847. + /* nothing */
  1848. + return 0;
  1849. +}
  1850. +
  1851. +static int __init zilog_init(void)
  1852. +{
  1853. + int ret;
  1854. +
  1855. + zilog_notify("Zilog/Hauppauge IR driver initializing\n");
  1856. +
  1857. + mutex_init(&tx_data_lock);
  1858. +
  1859. + request_module("firmware_class");
  1860. +
  1861. + ret = i2c_add_driver(&driver);
  1862. + if (ret)
  1863. + zilog_error("initialization failed\n");
  1864. + else
  1865. + zilog_notify("initialization complete\n");
  1866. +
  1867. + return ret;
  1868. +}
  1869. +
  1870. +static void __exit zilog_exit(void)
  1871. +{
  1872. + i2c_del_driver(&driver);
  1873. + /* if loaded */
  1874. + fw_unload();
  1875. + zilog_notify("Zilog/Hauppauge IR driver unloaded\n");
  1876. +}
  1877. +
  1878. +module_init(zilog_init);
  1879. +module_exit(zilog_exit);
  1880. +
  1881. +MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)");
  1882. +MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, "
  1883. + "Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver");
  1884. +MODULE_LICENSE("GPL");
  1885. +/* for compat with old name, which isn't all that accurate anymore */
  1886. +MODULE_ALIAS("lirc_pvr150");
  1887. +
  1888. +module_param(minor, int, 0444);
  1889. +MODULE_PARM_DESC(minor, "Preferred minor device number");
  1890. +
  1891. +module_param(debug, bool, 0644);
  1892. +MODULE_PARM_DESC(debug, "Enable debugging messages");
  1893. +
  1894. +module_param(disable_rx, bool, 0644);
  1895. +MODULE_PARM_DESC(disable_rx, "Disable the IR receiver device");
  1896. +
  1897. +module_param(disable_tx, bool, 0644);
  1898. +MODULE_PARM_DESC(disable_tx, "Disable the IR transmitter device");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement