hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/media/pci/ivtv/ivtvfb.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 On Screen Display cx23415 Framebuffer driver
34
....@@ -23,19 +24,6 @@
2324
2425 Copyright (C) 2006 Ian Armstrong <ian@iarmst.demon.co.uk>
2526
26
- This program is free software; you can redistribute it and/or modify
27
- it under the terms of the GNU General Public License as published by
28
- the Free Software Foundation; either version 2 of the License, or
29
- (at your option) any later version.
30
-
31
- This program is distributed in the hope that it will be useful,
32
- but WITHOUT ANY WARRANTY; without even the implied warranty of
33
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
- GNU General Public License for more details.
35
-
36
- You should have received a copy of the GNU General Public License
37
- along with this program; if not, write to the Free Software
38
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3927 */
4028
4129 #include "ivtv-driver.h"
....@@ -49,12 +37,13 @@
4937 #include <linux/ivtvfb.h>
5038
5139 #ifdef CONFIG_X86_64
52
-#include <asm/pat.h>
40
+#include <asm/memtype.h>
5341 #endif
5442
5543 /* card parameters */
5644 static int ivtvfb_card_id = -1;
5745 static int ivtvfb_debug = 0;
46
+static bool ivtvfb_force_pat = IS_ENABLED(CONFIG_VIDEO_FB_IVTV_FORCE_PAT);
5847 static bool osd_laced;
5948 static int osd_depth;
6049 static int osd_upper;
....@@ -64,6 +53,7 @@
6453
6554 module_param(ivtvfb_card_id, int, 0444);
6655 module_param_named(debug,ivtvfb_debug, int, 0644);
56
+module_param_named(force_pat, ivtvfb_force_pat, bool, 0644);
6757 module_param(osd_laced, bool, 0444);
6858 module_param(osd_depth, int, 0444);
6959 module_param(osd_upper, int, 0444);
....@@ -78,6 +68,9 @@
7868 MODULE_PARM_DESC(debug,
7969 "Debug level (bitmask). Default: errors only\n"
8070 "\t\t\t(debug = 3 gives full debugging)");
71
+
72
+MODULE_PARM_DESC(force_pat,
73
+ "Force initialization on x86 PAT-enabled systems (bool).\n");
8174
8275 /* Why upper, left, xres, yres, depth, laced ? To match terminology used
8376 by fbset.
....@@ -288,10 +281,10 @@
288281 /* Map User DMA */
289282 if (ivtv_udma_setup(itv, ivtv_dest_addr, userbuf, size_in_bytes) <= 0) {
290283 mutex_unlock(&itv->udma.lock);
291
- IVTVFB_WARN("ivtvfb_prep_dec_dma_to_device, Error with get_user_pages: %d bytes, %d pages returned\n",
284
+ IVTVFB_WARN("ivtvfb_prep_dec_dma_to_device, Error with pin_user_pages: %d bytes, %d pages returned\n",
292285 size_in_bytes, itv->udma.page_count);
293286
294
- /* get_user_pages must have failed completely */
287
+ /* pin_user_pages must have failed completely */
295288 return -EIO;
296289 }
297290
....@@ -356,7 +349,7 @@
356349 IVTVFB_WARN("ivtvfb_prep_frame: Count not a multiple of 4 (%d)\n", count);
357350
358351 /* Check Source */
359
- if (!access_ok(VERIFY_READ, source + dest_offset, count)) {
352
+ if (!access_ok(source + dest_offset, count)) {
360353 IVTVFB_WARN("Invalid userspace pointer %p\n", source);
361354
362355 IVTVFB_DEBUG_WARN("access_ok() failed for offset 0x%08lx source %p count %d\n",
....@@ -624,7 +617,7 @@
624617
625618 IVTVFB_DEBUG_INFO("ivtvfb_get_fix\n");
626619 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
627
- strlcpy(fix->id, "cx23415 TV out", sizeof(fix->id));
620
+ strscpy(fix->id, "cx23415 TV out", sizeof(fix->id));
628621 fix->smem_start = oi->video_pbase;
629622 fix->smem_len = oi->video_buffer_size;
630623 fix->type = FB_TYPE_PACKED_PIXELS;
....@@ -932,7 +925,7 @@
932925 return 0;
933926 }
934927
935
-static struct fb_ops ivtvfb_ops = {
928
+static const struct fb_ops ivtvfb_ops = {
936929 .owner = THIS_MODULE,
937930 .fb_write = ivtvfb_write,
938931 .fb_check_var = ivtvfb_check_var,
....@@ -1056,7 +1049,6 @@
10561049
10571050 oi->ivtvfb_info.node = -1;
10581051 oi->ivtvfb_info.flags = FBINFO_FLAG_DEFAULT;
1059
- oi->ivtvfb_info.fbops = &ivtvfb_ops;
10601052 oi->ivtvfb_info.par = itv;
10611053 oi->ivtvfb_info.var = oi->ivtvfb_defined;
10621054 oi->ivtvfb_info.fix = oi->ivtvfb_fix;
....@@ -1167,8 +1159,15 @@
11671159
11681160 #ifdef CONFIG_X86_64
11691161 if (pat_enabled()) {
1170
- pr_warn("ivtvfb needs PAT disabled, boot with nopat kernel parameter\n");
1171
- return -ENODEV;
1162
+ if (ivtvfb_force_pat) {
1163
+ pr_info("PAT is enabled. Write-combined framebuffer caching will be disabled.\n");
1164
+ pr_info("To enable caching, boot with nopat kernel parameter\n");
1165
+ } else {
1166
+ pr_warn("ivtvfb needs PAT disabled for write-combined framebuffer caching.\n");
1167
+ pr_warn("Boot with nopat kernel parameter to use caching, or use the\n");
1168
+ pr_warn("force_pat module parameter to run with caching disabled\n");
1169
+ return -ENODEV;
1170
+ }
11721171 }
11731172 #endif
11741173
....@@ -1220,6 +1219,11 @@
12201219
12211220 /* Allocate DMA */
12221221 ivtv_udma_alloc(itv);
1222
+ itv->streams[IVTV_DEC_STREAM_TYPE_YUV].vdev.device_caps |=
1223
+ V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
1224
+ itv->streams[IVTV_DEC_STREAM_TYPE_MPG].vdev.device_caps |=
1225
+ V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
1226
+ itv->v4l2_cap |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
12231227 return 0;
12241228
12251229 }
....@@ -1246,11 +1250,12 @@
12461250 struct osd_info *oi = itv->osd_info;
12471251
12481252 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
1249
- if (unregister_framebuffer(&itv->osd_info->ivtvfb_info)) {
1250
- IVTVFB_WARN("Framebuffer %d is in use, cannot unload\n",
1251
- itv->instance);
1252
- return 0;
1253
- }
1253
+ itv->streams[IVTV_DEC_STREAM_TYPE_YUV].vdev.device_caps &=
1254
+ ~V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
1255
+ itv->streams[IVTV_DEC_STREAM_TYPE_MPG].vdev.device_caps &=
1256
+ ~V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
1257
+ itv->v4l2_cap &= ~V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
1258
+ unregister_framebuffer(&itv->osd_info->ivtvfb_info);
12541259 IVTVFB_INFO("Unregister framebuffer %d\n", itv->instance);
12551260 itv->ivtvfb_restore = NULL;
12561261 ivtvfb_blank(FB_BLANK_VSYNC_SUSPEND, &oi->ivtvfb_info);