vesadrm.c (683058df13c7de4cf29fb4a929d431ca12313966) | vesadrm.c (6046b49bafff47726a377ef05dc55ef7dec01cbd) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2 3#include <linux/aperture.h> 4#include <linux/ioport.h> 5#include <linux/limits.h> 6#include <linux/platform_device.h> 7#include <linux/screen_info.h> 8 --- 22 unchanged lines hidden (view full) --- 31 32#define DRIVER_NAME "vesadrm" 33#define DRIVER_DESC "DRM driver for VESA platform devices" 34#define DRIVER_MAJOR 1 35#define DRIVER_MINOR 0 36 37#define VESADRM_GAMMA_LUT_SIZE 256 38 | 1// SPDX-License-Identifier: GPL-2.0-only 2 3#include <linux/aperture.h> 4#include <linux/ioport.h> 5#include <linux/limits.h> 6#include <linux/platform_device.h> 7#include <linux/screen_info.h> 8 --- 22 unchanged lines hidden (view full) --- 31 32#define DRIVER_NAME "vesadrm" 33#define DRIVER_DESC "DRM driver for VESA platform devices" 34#define DRIVER_MAJOR 1 35#define DRIVER_MINOR 0 36 37#define VESADRM_GAMMA_LUT_SIZE 256 38 |
39static int vesadrm_get_validated_int(struct drm_device *dev, const char *name, 40 u64 value, u32 max) 41{ 42 if (max > INT_MAX) 43 max = INT_MAX; 44 if (value > max) { 45 drm_err(dev, "%s of %llu exceeds maximum of %u\n", name, value, max); 46 return -EINVAL; 47 } 48 return value; 49} 50 51static int vesadrm_get_validated_int0(struct drm_device *dev, const char *name, 52 u64 value, u32 max) 53{ 54 if (!value) { 55 drm_err(dev, "%s of 0 not allowed\n", name); 56 return -EINVAL; 57 } 58 return vesadrm_get_validated_int(dev, name, value, max); 59} 60 | |
61static s64 vesadrm_get_validated_size0(struct drm_device *dev, const char *name, 62 u64 value, u64 max) 63{ 64 if (!value) { 65 drm_err(dev, "vesadrm: %s of 0 not allowed\n", name); 66 return -EINVAL; 67 } else if (value > max) { 68 drm_err(dev, "vesadrm: %s of %llu exceeds maximum of %llu\n", name, value, max); 69 return -EINVAL; 70 } 71 return value; 72} 73 74static int vesadrm_get_width_si(struct drm_device *dev, const struct screen_info *si) 75{ | 39static s64 vesadrm_get_validated_size0(struct drm_device *dev, const char *name, 40 u64 value, u64 max) 41{ 42 if (!value) { 43 drm_err(dev, "vesadrm: %s of 0 not allowed\n", name); 44 return -EINVAL; 45 } else if (value > max) { 46 drm_err(dev, "vesadrm: %s of %llu exceeds maximum of %llu\n", name, value, max); 47 return -EINVAL; 48 } 49 return value; 50} 51 52static int vesadrm_get_width_si(struct drm_device *dev, const struct screen_info *si) 53{ |
76 return vesadrm_get_validated_int0(dev, "width", si->lfb_width, U16_MAX); | 54 return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX); |
77} 78 79static int vesadrm_get_height_si(struct drm_device *dev, const struct screen_info *si) 80{ | 55} 56 57static int vesadrm_get_height_si(struct drm_device *dev, const struct screen_info *si) 58{ |
81 return vesadrm_get_validated_int0(dev, "height", si->lfb_height, U16_MAX); | 59 return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX); |
82} 83 84static struct resource *vesadrm_get_memory_si(struct drm_device *dev, 85 const struct screen_info *si, 86 struct resource *res) 87{ 88 ssize_t num; 89 --- 10 unchanged lines hidden (view full) --- 100 const struct drm_format_info *format, 101 unsigned int width, unsigned int height, u64 size) 102{ 103 u64 lfb_linelength = si->lfb_linelength; 104 105 if (!lfb_linelength) 106 lfb_linelength = drm_format_info_min_pitch(format, 0, width); 107 | 60} 61 62static struct resource *vesadrm_get_memory_si(struct drm_device *dev, 63 const struct screen_info *si, 64 struct resource *res) 65{ 66 ssize_t num; 67 --- 10 unchanged lines hidden (view full) --- 78 const struct drm_format_info *format, 79 unsigned int width, unsigned int height, u64 size) 80{ 81 u64 lfb_linelength = si->lfb_linelength; 82 83 if (!lfb_linelength) 84 lfb_linelength = drm_format_info_min_pitch(format, 0, width); 85 |
108 return vesadrm_get_validated_int0(dev, "stride", lfb_linelength, div64_u64(size, height)); | 86 return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength, 87 div64_u64(size, height)); |
109} 110 111static u64 vesadrm_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, 112 unsigned int height, unsigned int stride, u64 size) 113{ 114 u64 vsize = PAGE_ALIGN(height * stride); 115 116 return vesadrm_get_validated_size0(dev, "visible size", vsize, size); --- 546 unchanged lines hidden --- | 88} 89 90static u64 vesadrm_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, 91 unsigned int height, unsigned int stride, u64 size) 92{ 93 u64 vsize = PAGE_ALIGN(height * stride); 94 95 return vesadrm_get_validated_size0(dev, "visible size", vsize, size); --- 546 unchanged lines hidden --- |