Commit Graph

1200674 Commits

Author SHA1 Message Date
CrazyCat
c6af36f453 Merge pull request #393 from Vyacheslav-S/latest
Add support for TV tuner DVB-T2 AVerTV Mobile 510 (EW510)
2025-04-15 18:22:45 +03:00
Vyacheslav
494100fe99 Add support for TV tuner DVB-T2 AVerTV Mobile 510 (EW510) 2025-04-15 21:30:48 +07:00
CrazyCat
b4a40fd7cc media: pci/tbscapture2: Compatibility fix for 6.14+ kernels. 2025-04-06 18:38:25 +03:00
CrazyCat
b68595ce48 media: pci/saa716x: Fixed TBS 6991 config. 2025-03-27 18:56:45 +02:00
CrazyCat
aadd52af8e media: dvb-frontends/m88rs6060: Fixed enum definition. 2025-03-25 18:05:09 +02:00
CrazyCat
82569f482a Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest 2025-03-19 21:13:18 +02:00
CrazyCat
3c5176eb42 Revert "media: Convert from tasklet to BH workqueue"
This reverts commit 16ba295214.
2025-03-19 21:06:35 +02:00
CrazyCat
2945bc07ee Revert "media: drivers/media/dvb-core: copy user arrays safely"
This reverts commit 04e8cbcdad.
2025-03-19 21:05:59 +02:00
CrazyCat
239c9aeacd media: tuners/r850: dos2unix. 2025-03-19 20:56:26 +02:00
CrazyCat
a668e81971 media: pci/tbscapture2: Optimized for X86 SIMD. 2025-03-19 19:49:50 +02:00
CrazyCat
75a92ecbf1 Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest 2025-03-18 23:37:11 +02:00
Allen Pais
16ba295214 media: Convert from tasklet to BH workqueue
The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.

This patch converts drivers/media/* from tasklet to BH workqueue.

Based on the work done by Tejun Heo <tj@kernel.org>

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-03-18 23:36:28 +02:00
CrazyCat
faf2701510 Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest 2025-03-18 23:03:14 +02:00
Junlin Li
d7c508c5ad drivers: media: dvb-frontends/rtl2832: fix an out-of-bounds write error
Ensure index in rtl2832_pid_filter does not exceed 31 to prevent
out-of-bounds access.

dev->filters is a 32-bit value, so set_bit and clear_bit functions should
only operate on indices from 0 to 31. If index is 32, it will attempt to
access a non-existent 33rd bit, leading to out-of-bounds access.
Change the boundary check from index > 32 to index >= 32 to resolve this
issue.

Signed-off-by: Junlin Li <make24@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: 4b01e01a81 ("[media] rtl2832: implement PID filter")
[hverkuil: added fixes tag, rtl2830_pid_filter -> rtl2832_pid_filter in logmsg]
2025-03-18 19:33:10 +02:00
Arnd Bergmann
7457f7d86c media: cxd2841er: fix 64-bit division on gcc-9
It appears that do_div() once more gets confused by a complex
expression that ends up not quite being constant despite
__builtin_constant_p() thinking it is:

ERROR: modpost: "__aeabi_uldivmod" [drivers/media/dvb-frontends/cxd2841er.ko] undefined!

Use div_u64() instead, forcing the expression to be evaluated
first, and making it a bit more readable.

Cc: Dan Carpenter <dan.carpenter@linaro.org>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Closes: https://lore.kernel.org/linux-media/CA+G9fYvvNm-aYodLaAwwTjEGtX0YxR-1R14FOA5aHKt0sSVsYg@mail.gmail.com/
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Closes: https://lore.kernel.org/linux-media/CA+G9fYvvNm-aYodLaAwwTjEGtX0YxR-1R14FOA5aHKt0sSVsYg@mail.gmail.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
[hverkuil: added Closes tags]
2025-03-18 19:29:10 +02:00
jieqing.wang
56f6f0e47f media: fix secfeed undefined when filter alloc fail
In dvb_dmxdev_filter_start, when secfeed allocate secfilter fail.
  the secfeed of current dmxfilter, need set to NULL;
  Instead of call start_filtering, which already handled in
  dvb_dmxdev_feed_restart

Signed-off-by: jieqing.wang <standback@126.com>
Link: https://lore.kernel.org/r/20221201052705.2313911-1-standback@126.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-03-17 23:04:11 +02:00
Mauro Carvalho Chehab
a351a382c8 media: dvb_frontend: don't play tricks with underflow values
fepriv->auto_sub_step is unsigned. Setting it to -1 is just a
trick to avoid calling continue, as reported by Coverity.

It relies to have this code just afterwards:

	if (!ready) fepriv->auto_sub_step++;

Simplify the code by simply setting it to zero and use
continue to return to the while loop.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-03-17 23:02:48 +02:00
Kevin Hao
df21b7152c media: dvb_frontend: Use wait_event_freezable_timeout() for freezable kthread
A freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. So for the following snippet of code in a kernel thread loop:
  wait_event_interruptible_timeout();
  try_to_freeze();

We can change it to a simple wait_event_freezable_timeout() and
then eliminate a function call.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-03-17 23:02:28 +02:00
Philipp Stanner
04e8cbcdad media: drivers/media/dvb-core: copy user arrays safely
At several positions in dvb_frontend.c, memdup_user() is utilized to
copy userspace arrays. This is done without overflow checks.

Use the new wrapper memdup_array_user() to copy the arrays more safely.

Link: https://lore.kernel.org/linux-media/20231102191633.52592-2-pstanner@redhat.com
Suggested-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2025-03-17 23:02:08 +02:00
Mauro Carvalho Chehab
8eefe2a716 media: dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set
When CONFIG_DVB_DYNAMIC_MINORS, ret is not initialized, and a
semaphore is left at the wrong state, in case of errors.

Make the code simpler and avoid mistakes by having just one error
check logic used weather DVB_DYNAMIC_MINORS is used or not.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202410201717.ULWWdJv8-lkp@intel.com/
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/9e067488d8935b8cf00959764a1fa5de85d65725.1730926254.git.mchehab+huawei@kernel.org
2025-03-17 23:00:08 +02:00
Mauro Carvalho Chehab
53e6d7adf4 media: dvbdev: prevent the risk of out of memory access
The dvbdev contains a static variable used to store dvb minors.

The behavior of it depends if CONFIG_DVB_DYNAMIC_MINORS is set
or not. When not set, dvb_register_device() won't check for
boundaries, as it will rely that a previous call to
dvb_register_adapter() would already be enforcing it.

On a similar way, dvb_device_open() uses the assumption
that the register functions already did the needed checks.

This can be fragile if some device ends using different
calls. This also generate warnings on static check analysers
like Coverity.

So, add explicit guards to prevent potential risk of OOM issues.

Fixes: 5dd3f30710 ("V4L/DVB (9361): Dynamic DVB minor allocation")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-03-17 22:59:49 +02:00
Ricardo Ribalda
1b4240d316 media: dvbdev: Initialize sbuf
Because the size passed to copy_from_user() cannot be known beforehand,
it needs to be checked during runtime with check_object_size. That makes
gcc believe that the content of sbuf can be used before init.

Fix:
./include/linux/thread_info.h:215:17: warning: ‘sbuf’ may be used uninitialized [-Wmaybe-uninitialized]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-03-17 22:59:26 +02:00
Zhipeng Lu
dcd0b3c0f8 media: edia: dvbdev: fix a use-after-free
In dvb_register_device, *pdvbdev is set equal to dvbdev, which is freed
in several error-handling paths. However, *pdvbdev is not set to NULL
after dvbdev's deallocation, causing use-after-frees in many places,
for example, in the following call chain:

budget_register
  |-> dvb_dmxdev_init
        |-> dvb_register_device
  |-> dvb_dmxdev_release
        |-> dvb_unregister_device
              |-> dvb_remove_device
                    |-> dvb_device_put
                          |-> kref_put

When calling dvb_unregister_device, dmxdev->dvbdev (i.e. *pdvbdev in
dvb_register_device) could point to memory that had been freed in
dvb_register_device. Thereafter, this pointer is transferred to
kref_put and triggering a use-after-free.

Link: https://lore.kernel.org/linux-media/20240203134046.3120099-1-alexious@zju.edu.cn
Fixes: b619010247 ("V4L/DVB (5244): Dvbdev: fix illegal re-usage of fileoperations struct")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2025-03-17 22:59:12 +02:00
Dan Carpenter
6868fb5df0 media: dvbdev: drop refcount on error path in dvb_device_open()
If call to file->f_op->open() fails, then call dvb_device_put(dvbdev).

Fixes: 0fc044b2b5 ("media: dvbdev: adopts refcnt to avoid UAF")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-03-17 22:58:33 +02:00
CrazyCat
a8b05e2cf2 media: pci/tbscapture2: Compile only for X86. 2025-03-17 19:47:29 +02:00
Davin622
2a06970f80 Added support for tbs6514 V2 2025-03-17 15:54:06 +08:00
Davin622
7d6cc50725 Added support for r850 chip 2025-03-17 15:46:06 +08:00
Davin622
0639a85adc Optimized the gx1503 module 2025-03-17 15:33:06 +08:00
CrazyCat
197f7e3315 media: dvb-frontends/mxl58x: Fixes. 2025-03-16 23:46:40 +02:00
CrazyCat
4adf72a0f9 Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest 2025-03-16 23:31:06 +02:00
Ricardo Ribalda
3a2f7cc55f media: dvb-frontend/mxl5xx: Refactor struct MBIN_FILE_T and MBIN_SEGMENT_T
Replace the older style one-element array with a flexible array member.
There does not seem to be any allocation for these structs in the code, so
no more code changes are required.

The following cocci warnings are fixed:
drivers/media/dvb-frontends/mxl5xx_defs.h:182:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/dvb-frontends/mxl5xx_defs.h:171:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-03-16 23:30:26 +02:00
Nathan Chancellor
a032976080 media: mxl5xx: Move xpt structures off stack
When building for LoongArch with clang 18.0.0, the stack usage of
probe() is larger than the allowed 2048 bytes:

  drivers/media/dvb-frontends/mxl5xx.c:1698:12: warning: stack frame size (2368) exceeds limit (2048) in 'probe' [-Wframe-larger-than]
   1698 | static int probe(struct mxl *state, struct mxl5xx_cfg *cfg)
        |            ^
  1 warning generated.

This is the result of the linked LLVM commit, which changes how the
arrays of structures in config_ts() get handled with
CONFIG_INIT_STACK_ZERO and CONFIG_INIT_STACK_PATTERN, which causes the
above warning in combination with inlining, as config_ts() gets inlined
into probe().

This warning can be easily fixed by moving the array of structures off
of the stackvia 'static const', which is a better location for these
variables anyways because they are static data that is only ever read
from, never modified, so allocating the stack space is wasteful.

This drops the stack usage from 2368 bytes to 256 bytes with the same
compiler and configuration.

Link: https://lore.kernel.org/linux-media/20240111-dvb-mxl5xx-move-structs-off-stack-v1-1-ca4230e67c11@kernel.org
Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/1977
Link: afe8b93ffd
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2025-03-16 23:28:41 +02:00
CrazyCat
1dcc2b53e9 media: pci/tbscapture2: New generation PCIe x4 HDMI capture card driver. TBS 6314R support. 2025-02-27 16:55:17 +02:00
CrazyCat
7220890237 Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest 2025-02-12 20:02:20 +02:00
CrazyCat
491c301945 media: Switch back to struct platform_driver::remove()
After commit 0edb555a65d1 ("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.

Convert all platform drivers below drivers/media to use .remove(), with
the eventual goal to drop struct platform_driver::remove_new(). As
.remove() and .remove_new() have the same prototypes, conversion is done
by just changing the structure member name in the driver initializer.
2025-02-10 20:14:08 +02:00
Uros Bizjak
4e87c465d4 media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
Include <linux/prandom.h> to allow the removal of legacy
inclusion of <linux/prandom.h> from <linux/random.h>.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2025-02-10 20:03:26 +02:00
Sean Young
cc03a3bbaa media: pwm-ir-tx: Trigger edges from hrtimer interrupt context
This makes the generated IR much more precise. Before this change, the
driver is unreliable and many users opted to use gpio-ir-tx instead.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2025-02-10 19:51:58 +02:00
Sean Young
61578a5f53 pwm: Rename pwm_apply_state() to pwm_apply_might_sleep()
In order to introduce a pwm api which can be used from atomic context,
we will need two functions for applying pwm changes:

	int pwm_apply_might_sleep(struct pwm *, struct pwm_state *);
	int pwm_apply_atomic(struct pwm *, struct pwm_state *);

This commit just deals with renaming pwm_apply_state(), a following
commit will introduce the pwm_apply_atomic() function.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> # for input
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2025-02-10 19:50:54 +02:00
Rob Herring
28fe9d2012 media: ir-hix5hd2: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-02-10 19:40:40 +02:00
Uwe Kleine-König
e8719007b8 media: Switch back to struct platform_driver::remove()
After commit 0edb555a65d1 ("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.

Convert all platform drivers below drivers/media to use .remove(), with
the eventual goal to drop struct platform_driver::remove_new(). As
.remove() and .remove_new() have the same prototypes, conversion is done
by just changing the structure member name in the driver initializer.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-02-10 18:59:37 +02:00
Peter Zijlstra
c5ab1bec6a module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498f ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.

Scripted using

  git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
  do
    awk -i inplace '
      /^#define EXPORT_SYMBOL_NS/ {
        gsub(/__stringify\(ns\)/, "ns");
        print;
        next;
      }
      /^#define MODULE_IMPORT_NS/ {
        gsub(/__stringify\(ns\)/, "ns");
        print;
        next;
      }
      /MODULE_IMPORT_NS/ {
        $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
      }
      /EXPORT_SYMBOL_NS/ {
        if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
  	if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
  	    $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
  	    $0 !~ /^my/) {
  	  getline line;
  	  gsub(/[[:space:]]*\\$/, "");
  	  gsub(/[[:space:]]/, "", line);
  	  $0 = $0 " " line;
  	}

  	$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
  		    "\\1(\\2, \"\\3\")", "g");
        }
      }
      { print }' $file;
  done

Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2025-02-10 18:57:39 +02:00
Yang Yingliang
2a7ea99ca6 media: usb/msi2500: switch to use spi_alloc_host()
Switch to use modern name function spi_alloc_host().

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://patch.msgid.link/20240902125947.1368-2-yangyingliang@huaweicloud.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-10 18:53:06 +02:00
Yang Yingliang
610cff29b9 media: netup_unidvb: switch to use devm_spi_alloc_host()
Switch to use modern name function devm_spi_alloc_host().

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://patch.msgid.link/20240902125947.1368-3-yangyingliang@huaweicloud.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-10 18:51:34 +02:00
CrazyCat
8d6283e035 media: pci/tbscapture: Rename module and cleanup. 2025-01-26 18:03:21 +02:00
CrazyCat
f52def659a media: dvb-frontends/stid135: Optional timeout for signal statistic retrieve. 2025-01-25 23:31:25 +02:00
CrazyCat
6ba271e6fb media: dvb-frontend/stid135: Fixed BBFrame L3 encapsulation for GCS, GSE-HEM. 2024-12-19 17:51:08 +02:00
tbslucy
ca3b5b0028 add to support TBS690B-Lite 2024-12-16 18:07:54 +08:00
CrazyCat
cf8cf4c060 Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest 2024-12-12 19:20:25 +02:00
CrazyCat
fb40feb6f2 media: rc: add missing io.h
In many remote control drivers the io.h is implied by others.  This is not
good as it prevents from cleanups done in other headers.  Add missing
include.
2024-12-12 19:18:50 +02:00
CrazyCat
ab0cbda3aa media: dvb-frontends/mxl58x: move asm/unaligned.h to linux/unaligned.h
move asm/unaligned.h to linux/unaligned.h
2024-12-11 20:02:26 +02:00