Lines Matching +full:video +full:- +full:mem

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
6 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
10 #include "ivtv-driver.h"
11 #include "ivtv-mailbox.h"
12 #include "ivtv-firmware.h"
13 #include "ivtv-yuv.h"
14 #include "ivtv-ioctl.h"
15 #include "ivtv-cards.h"
33 #define IVTV_DECODE_INIT_MPEG_FILENAME "v4l-cx2341x-init.mpg"
40 static int load_fw_direct(const char *fn, volatile u8 __iomem *mem, struct ivtv *itv, long size) in load_fw_direct() argument
46 if (retries && request_firmware(&fw, fn, &itv->pdev->dev) == 0) { in load_fw_direct()
48 volatile u32 __iomem *dst = (volatile u32 __iomem *)mem; in load_fw_direct()
49 const u32 *src = (const u32 *)fw->data; in load_fw_direct()
51 if (fw->size != size) { in load_fw_direct()
54 see if at least the right-sized file was loaded. If not, then we in load_fw_direct()
56 IVTV_INFO("Retry: file loaded was not %s (expected size %ld, got %zu)\n", fn, size, fw->size); in load_fw_direct()
58 retries--; in load_fw_direct()
61 for (i = 0; i < fw->size; i += 4) { in load_fw_direct()
67 IVTV_INFO("Loaded %s firmware (%zu bytes)\n", fn, fw->size); in load_fw_direct()
73 return -ENOMEM; in load_fw_direct()
79 if (itv->has_cx23415 && itv->dec_mbox.mbox) in ivtv_halt_firmware()
81 if (itv->enc_mbox.mbox) in ivtv_halt_firmware()
85 itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL; in ivtv_halt_firmware()
97 if (!itv->has_cx23415) in ivtv_halt_firmware()
110 IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n"); in ivtv_halt_firmware()
116 if (itv->has_cx23415) { in ivtv_halt_firmware()
117 IVTV_DEBUG_INFO("init Decoder SDRAM pre-charge\n"); in ivtv_halt_firmware()
139 if (itv->has_cx23415) { in ivtv_firmware_versions()
150 itv->enc_mem, itv, IVTV_FW_ENC_SIZE) != IVTV_FW_ENC_SIZE) { in ivtv_firmware_copy()
152 return -3; in ivtv_firmware_copy()
154 if (!itv->has_cx23415) in ivtv_firmware_copy()
159 itv->dec_mem, itv, IVTV_FW_DEC_SIZE) != IVTV_FW_DEC_SIZE) { in ivtv_firmware_copy()
161 return -1; in ivtv_firmware_copy()
166 static volatile struct ivtv_mailbox __iomem *ivtv_search_mailbox(const volatile u8 __iomem *mem, u3… in ivtv_search_mailbox() argument
170 /* mailbox is preceded by a 16 byte 'magic cookie' starting at a 256-byte in ivtv_search_mailbox()
173 if (readl(mem + i) == 0x12345678 && in ivtv_search_mailbox()
174 readl(mem + i + 4) == 0x34567812 && in ivtv_search_mailbox()
175 readl(mem + i + 8) == 0x56781234 && in ivtv_search_mailbox()
176 readl(mem + i + 12) == 0x78123456) { in ivtv_search_mailbox()
177 return (volatile struct ivtv_mailbox __iomem *)(mem + i + 16); in ivtv_search_mailbox()
199 if (itv->has_cx23415) in ivtv_firmware_init()
206 itv->enc_mbox.mbox = ivtv_search_mailbox(itv->enc_mem, IVTV_ENCODER_SIZE); in ivtv_firmware_init()
207 if (itv->enc_mbox.mbox == NULL) in ivtv_firmware_init()
211 itv->enc_mbox.mbox = NULL; in ivtv_firmware_init()
213 if (itv->enc_mbox.mbox == NULL) in ivtv_firmware_init()
214 return -ENODEV; in ivtv_firmware_init()
216 if (!itv->has_cx23415) in ivtv_firmware_init()
219 itv->dec_mbox.mbox = ivtv_search_mailbox(itv->dec_mem, IVTV_DECODER_SIZE); in ivtv_firmware_init()
220 if (itv->dec_mbox.mbox == NULL) { in ivtv_firmware_init()
222 } else if (itv->has_cx23415 && ivtv_vapi(itv, CX2341X_DEC_PING_FW, 0)) { in ivtv_firmware_init()
224 itv->dec_mbox.mbox = NULL; in ivtv_firmware_init()
229 return itv->dec_mbox.mbox ? 0 : -ENODEV; in ivtv_firmware_init()
239 data[1] = itv->cxhdl.width; /* YUV source width */ in ivtv_init_mpeg_decoder()
240 data[2] = itv->cxhdl.height; in ivtv_init_mpeg_decoder()
241 data[3] = itv->cxhdl.audio_properties; /* Audio settings to use, in ivtv_init_mpeg_decoder()
252 ivtv_api_get_data(&itv->dec_mbox, IVTV_MBOX_DMA, 2, data); in ivtv_init_mpeg_decoder()
253 mem_offset = itv->dec_mem + data[1]; in ivtv_init_mpeg_decoder()
272 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_firmware_restart()
274 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, in ivtv_firmware_restart()
276 itv->card->video_outputs[itv->active_output].video_output, in ivtv_firmware_restart()
279 mutex_lock(&itv->udma.lock); in ivtv_firmware_restart()
283 mutex_unlock(&itv->udma.lock); in ivtv_firmware_restart()
290 /* Restore encoder video standard */ in ivtv_firmware_restart()
291 std = itv->std; in ivtv_firmware_restart()
292 itv->std = 0; in ivtv_firmware_restart()
295 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_firmware_restart()
298 /* Restore decoder video standard */ in ivtv_firmware_restart()
299 std = itv->std_out; in ivtv_firmware_restart()
300 itv->std_out = 0; in ivtv_firmware_restart()
304 if (itv->ivtvfb_restore) in ivtv_firmware_restart()
305 itv->ivtvfb_restore(itv); in ivtv_firmware_restart()
311 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, in ivtv_firmware_restart()
313 itv->card->video_outputs[itv->active_output].video_output, in ivtv_firmware_restart()
317 mutex_unlock(&itv->udma.lock); in ivtv_firmware_restart()
330 res = -1; in ivtv_firmware_check()
334 if (!res && !atomic_read(&itv->capturing) && in ivtv_firmware_check()
335 (!atomic_read(&itv->decoding) || in ivtv_firmware_check()
336 (atomic_read(&itv->decoding) < 2 && test_bit(IVTV_F_I_DEC_YUV, in ivtv_firmware_check()
337 &itv->i_flags)))) { in ivtv_firmware_check()
341 res = -2; in ivtv_firmware_check()
345 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_firmware_check()
347 if (res != -2 && read_dec(0x100) != read_dec(0x104)) { in ivtv_firmware_check()
353 res = -1; in ivtv_firmware_check()
360 res = -1; in ivtv_firmware_check()
365 if (res && !atomic_read(&itv->capturing) && in ivtv_firmware_check()
366 !atomic_read(&itv->decoding)) { in ivtv_firmware_check()
367 IVTV_INFO("Detected in %s that firmware had failed - Reloading\n", in ivtv_firmware_check()
377 res = -EAGAIN; in ivtv_firmware_check()
382 res = -EIO; in ivtv_firmware_check()