Lines Matching +full:video +full:- +full:firmware

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 ivtv firmware functions.
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"
16 #include <linux/firmware.h>
33 #define IVTV_DECODE_INIT_MPEG_FILENAME "v4l-cx2341x-init.mpg"
36 /* Encoder/decoder firmware sizes */
42 const struct firmware *fw = NULL; in load_fw_direct()
46 if (retries && request_firmware(&fw, fn, &itv->pdev->dev) == 0) { 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()
52 /* Due to race conditions in firmware loading (esp. with udev <0.95) 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()
71 IVTV_ERR("Unable to open firmware %s (must be %ld bytes)\n", fn, size); in load_fw_direct()
72 IVTV_ERR("Did you put the firmware in the hotplug firmware directory?\n"); in load_fw_direct()
73 return -ENOMEM; in load_fw_direct()
78 IVTV_DEBUG_INFO("Preparing for firmware halt.\n"); in ivtv_halt_firmware()
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()
137 IVTV_WARN("Recommended firmware version is 0x02060039.\n"); in ivtv_firmware_versions()
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()
151 IVTV_DEBUG_WARN("failed loading encoder firmware\n"); 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()
160 IVTV_DEBUG_WARN("failed loading decoder firmware\n"); in ivtv_firmware_copy()
161 return -1; in ivtv_firmware_copy()
170 /* mailbox is preceded by a 16 byte 'magic cookie' starting at a 256-byte in ivtv_search_mailbox()
189 /* load firmware */ in ivtv_firmware_init()
192 IVTV_DEBUG_WARN("Error %d loading firmware\n", err); in ivtv_firmware_init()
196 /* start firmware */ in ivtv_firmware_init()
199 if (itv->has_cx23415) in ivtv_firmware_init()
205 /* find mailboxes and ping firmware */ 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()
210 IVTV_ERR("Encoder firmware dead!\n"); 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()
223 IVTV_ERR("Decoder firmware dead!\n"); in ivtv_firmware_init()
224 itv->dec_mbox.mbox = NULL; in ivtv_firmware_init()
226 /* Firmware okay, so check yuv output filter table */ 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()
321 /* Check firmware running state. The checks fall through
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()
376 IVTV_INFO("Firmware restart okay\n"); in ivtv_firmware_check()
377 res = -EAGAIN; in ivtv_firmware_check()
379 IVTV_INFO("Firmware restart failed\n"); in ivtv_firmware_check()
382 res = -EIO; in ivtv_firmware_check()