Lines Matching defs:av7110
2 * av7110_hw.c: av7110 low level hardware access and firmware interface
38 #include "av7110.h"
50 int av7110_debiwrite(struct av7110 *av7110, u32 config,
53 struct saa7146_dev *dev = av7110->dev;
59 if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
67 saa7146_write(dev, DEBI_AD, av7110->debi_bus);
73 u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count)
75 struct saa7146_dev *dev = av7110->dev;
82 if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
86 saa7146_write(dev, DEBI_AD, av7110->debi_bus);
93 if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
105 /* av7110 ARM core boot stuff */
107 static int waitdebi(struct av7110 *av7110, int adr, int state)
111 dprintk(4, "%p\n", av7110);
114 if (irdebi(av7110, DEBINOSWAP, adr, 0, 2) == state)
121 static int load_dram(struct av7110 *av7110, u32 *data, int len)
127 dprintk(4, "%p\n", av7110);
134 if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
139 mwdebi(av7110, DEBISWAB, bootblock,
142 iwdebi(av7110, DEBISWAB, AV7110_BOOT_BASE, swab32(base), 4);
143 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, AV7110_BOOT_MAX_SIZE, 2);
144 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
149 if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
154 mwdebi(av7110, DEBISWAB, bootblock,
157 mwdebi(av7110, DEBISWAB, bootblock,
160 iwdebi(av7110, DEBISWAB, AV7110_BOOT_BASE, swab32(base), 4);
161 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, rest, 2);
162 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
164 if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
168 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, 0, 2);
169 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
170 if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_AV7110_BOOT_COMPLETE) < 0) {
178 /* we cannot write av7110 DRAM directly, so load a bootloader into
180 int av7110_bootarm(struct av7110 *av7110)
183 const char *fw_name = "av7110/bootcode.bin";
184 struct saa7146_dev *dev = av7110->dev;
188 dprintk(4, "%p\n", av7110);
190 av7110->arm_ready = 0;
195 SAA7146_IER_DISABLE(av7110->dev, MASK_03 | MASK_19);
196 SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
199 saa7146_write(av7110->dev, MC1, 0x08800880);
200 saa7146_write(av7110->dev, DD1_STREAM_B, 0x00000000);
201 saa7146_write(av7110->dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
204 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
205 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
207 if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) {
214 iwdebi(av7110, DEBISWAP, DPRAM_BASE + i, 0x00, 4);
230 mwdebi(av7110, DEBISWAB, DPRAM_BASE, fw->data, fw->size);
232 iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
234 if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
243 if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0) {
253 mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram);
255 if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
263 //ARM_ClearIrq(av7110);
264 ARM_ResetMailBox(av7110);
265 SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
266 SAA7146_IER_ENABLE(av7110->dev, MASK_03);
268 av7110->arm_errors = 0;
269 av7110->arm_ready = 1;
272 MODULE_FIRMWARE("av7110/bootcode.bin");
278 int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
284 if (FW_VERSION(av7110->arm_app) <= 0x261c) {
294 if (mutex_lock_interruptible(&av7110->dcomlock))
296 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
297 mutex_unlock(&av7110->dcomlock);
310 static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
319 // dprintk(4, "%p\n", av7110);
321 if (!av7110->arm_ready) {
329 if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
333 av7110->arm_errors++;
339 if (FW_VERSION(av7110->arm_app) <= 0x261f)
340 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
346 if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
371 if (FW_VERSION(av7110->arm_app) >= 0x261d) {
386 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
397 av7110->arm_errors++;
405 wdebi(av7110, DEBINOSWAP, COMMAND + 2 * i, (u32) buf[i], 2);
408 wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2);
410 wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2);
412 wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);
414 if (FW_VERSION(av7110->arm_app) <= 0x261f)
415 wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);
421 if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
431 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
445 static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
449 // dprintk(4, "%p\n", av7110);
451 if (!av7110->arm_ready) {
455 if (mutex_lock_interruptible(&av7110->dcomlock))
458 ret = __av7110_send_fw_cmd(av7110, buf, length);
459 mutex_unlock(&av7110->dcomlock);
466 int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
472 // dprintk(4, "%p\n", av7110);
484 ret = av7110_send_fw_cmd(av7110, buf, num + 2);
491 int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
501 dprintk(4, "%p\n", av7110);
503 if (!av7110->arm_ready) {
508 if (mutex_lock_interruptible(&av7110->dcomlock))
511 if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) {
512 mutex_unlock(&av7110->dcomlock);
520 if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
524 mutex_unlock(&av7110->dcomlock);
536 if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
540 mutex_unlock(&av7110->dcomlock);
548 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
551 mutex_unlock(&av7110->dcomlock);
556 mutex_unlock(&av7110->dcomlock);
562 reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2);
564 mutex_unlock(&av7110->dcomlock);
568 static int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length)
571 ret = av7110_fw_request(av7110, &tag, 0, buf, length);
583 int av7110_firmversion(struct av7110 *av7110)
588 dprintk(4, "%p\n", av7110);
590 if (av7110_fw_query(av7110, tag, buf, 16)) {
592 av7110->dvb_adapter.num);
596 av7110->arm_fw = (buf[0] << 16) + buf[1];
597 av7110->arm_rtsl = (buf[2] << 16) + buf[3];
598 av7110->arm_vid = (buf[4] << 16) + buf[5];
599 av7110->arm_app = (buf[6] << 16) + buf[7];
600 av7110->avtype = (buf[8] << 16) + buf[9];
603 av7110->dvb_adapter.num, av7110->arm_fw,
604 av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app);
607 if (FW_CI_LL_SUPPORT(av7110->arm_app))
609 av7110->dvb_adapter.num);
612 av7110->dvb_adapter.num);
618 int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long burst)
624 dprintk(4, "%p\n", av7110);
640 ret = av7110_send_fw_cmd(av7110, buf, 18);
649 static inline int SetColorBlend(struct av7110 *av7110, u8 windownr)
651 return av7110_fw_cmd(av7110, COMTYPE_OSD, SetCBlend, 1, windownr);
654 static inline int SetBlend_(struct av7110 *av7110, u8 windownr,
657 return av7110_fw_cmd(av7110, COMTYPE_OSD, SetBlend, 4,
661 static inline int SetColor_(struct av7110 *av7110, u8 windownr,
664 return av7110_fw_cmd(av7110, COMTYPE_OSD, SetColor, 5,
668 static inline int SetFont(struct av7110 *av7110, u8 windownr, u8 fontsize,
671 return av7110_fw_cmd(av7110, COMTYPE_OSD, Set_Font, 4,
675 static int FlushText(struct av7110 *av7110)
680 if (mutex_lock_interruptible(&av7110->dcomlock))
685 if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0)
690 mutex_unlock(&av7110->dcomlock);
695 mutex_unlock(&av7110->dcomlock);
699 static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, char *buf)
706 if (mutex_lock_interruptible(&av7110->dcomlock))
712 if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0)
717 mutex_unlock(&av7110->dcomlock);
726 if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
731 mutex_unlock(&av7110->dcomlock);
738 wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2,
741 wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2);
742 ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
743 mutex_unlock(&av7110->dcomlock);
749 static inline int DrawLine(struct av7110 *av7110, u8 windownr,
752 return av7110_fw_cmd(av7110, COMTYPE_OSD, DLine, 6,
756 static inline int DrawBlock(struct av7110 *av7110, u8 windownr,
759 return av7110_fw_cmd(av7110, COMTYPE_OSD, DBox, 6,
763 static inline int HideWindow(struct av7110 *av7110, u8 windownr)
765 return av7110_fw_cmd(av7110, COMTYPE_OSD, WHide, 1, windownr);
768 static inline int MoveWindowRel(struct av7110 *av7110, u8 windownr, u16 x, u16 y)
770 return av7110_fw_cmd(av7110, COMTYPE_OSD, WMoveD, 3, windownr, x, y);
773 static inline int MoveWindowAbs(struct av7110 *av7110, u8 windownr, u16 x, u16 y)
775 return av7110_fw_cmd(av7110, COMTYPE_OSD, WMoveA, 3, windownr, x, y);
778 static inline int DestroyOSDWindow(struct av7110 *av7110, u8 windownr)
780 return av7110_fw_cmd(av7110, COMTYPE_OSD, WDestroy, 1, windownr);
783 static inline int CreateOSDWindow(struct av7110 *av7110, u8 windownr,
787 return av7110_fw_cmd(av7110, COMTYPE_OSD, WCreate, 4,
799 static inline int WaitUntilBmpLoaded(struct av7110 *av7110)
801 int ret = wait_event_timeout(av7110->bmpq,
802 av7110->bmp_state != BMP_LOADING, 10*HZ);
805 ret, av7110->bmp_state);
806 av7110->bmp_state = BMP_NONE;
812 static inline int LoadBitmap(struct av7110 *av7110,
822 dprintk(4, "%p\n", av7110);
824 format = bpp2bit[av7110->osdbpp[av7110->osdwin]];
826 av7110->bmp_state = BMP_LOADING;
836 av7110->bmp_state = BMP_NONE;
839 av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8;
840 av7110->bmpp = 0;
841 if (av7110->bmplen > 32768) {
842 av7110->bmp_state = BMP_NONE;
846 if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) {
847 av7110->bmp_state = BMP_NONE;
853 c = ((u8 *)av7110->bmpbuf)[1024 + i * delta + delta - 1];
855 c |= (((u8 *)av7110->bmpbuf)[1024 + i * delta + d]
857 ((u8 *)av7110->bmpbuf)[1024 + i] = c;
861 av7110->bmplen += 1024;
862 dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen);
863 ret = av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy);
865 ret = WaitUntilBmpLoaded(av7110);
869 static int BlitBitmap(struct av7110 *av7110, u16 x, u16 y)
871 dprintk(4, "%p\n", av7110);
873 return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, av7110->osdwin, x, y, 0);
876 static inline int ReleaseBitmap(struct av7110 *av7110)
878 dprintk(4, "%p\n", av7110);
880 if (av7110->bmp_state != BMP_LOADED && FW_VERSION(av7110->arm_app) < 0x261e)
882 if (av7110->bmp_state == BMP_LOADING)
884 av7110->bmp_state = BMP_NONE;
885 return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0);
904 static int OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend)
914 ret = SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
917 ret = SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
922 static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last)
939 wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i * 4, yuv, 4);
941 return av7110_fw_cmd(av7110, COMTYPE_OSD, Set_Palette, 4,
942 av7110->osdwin,
943 bpp2pal[av7110->osdbpp[av7110->osdwin]],
947 static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
960 bpp = av7110->osdbpp[av7110->osdwin] + 1;
967 if (av7110->bmp_state == BMP_LOADING) {
969 BUG_ON (FW_VERSION(av7110->arm_app) >= 0x261e);
970 rc = WaitUntilBmpLoaded(av7110);
980 rc = LoadBitmap(av7110, w, lpb, inc, data);
983 rc = BlitBitmap(av7110, x0, y0 + i * lpb);
989 rc = LoadBitmap(av7110, w, brest / bpl, inc, data);
991 rc = BlitBitmap(av7110, x0, y0 + bnum * lpb);
993 release_rc = ReleaseBitmap(av7110);
1001 int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
1005 if (mutex_lock_interruptible(&av7110->osd_mutex))
1010 ret = DestroyOSDWindow(av7110, av7110->osdwin);
1013 av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7;
1014 ret = CreateOSDWindow(av7110, av7110->osdwin,
1015 bpp2bit[av7110->osdbpp[av7110->osdwin]],
1020 ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
1023 ret = SetColorBlend(av7110, av7110->osdwin);
1027 ret = MoveWindowRel(av7110, av7110->osdwin, 0, 0);
1030 ret = HideWindow(av7110, av7110->osdwin);
1033 ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0);
1036 ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color);
1039 ret = OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1);
1042 if (FW_VERSION(av7110->arm_app) >= 0x2618)
1043 ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0);
1057 ret = OSDSetColor(av7110, dc->color + i, r, g, b, blend);
1064 ret = DrawLine(av7110, av7110->osdwin,
1071 ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
1074 ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
1078 ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
1082 ret = DrawLine(av7110, av7110->osdwin,
1096 ret = SetFont(av7110, av7110->osdwin, dc->x1,
1099 ret = FlushText(av7110);
1101 ret = WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf);
1108 av7110->osdwin = dc->x0;
1113 ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
1115 ret = SetColorBlend(av7110, av7110->osdwin);
1123 av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1;
1125 av7110->osdbpp[av7110->osdwin] = 0;
1126 ret = CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
1131 ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
1133 ret = SetColorBlend(av7110, av7110->osdwin);
1141 mutex_unlock(&av7110->osd_mutex);
1150 int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap)
1154 if (FW_4M_SDRAM(av7110->arm_app))