From 4b9e73fcb450a75afaf952182a9befb8f9c5fc2d Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sun, 13 Mar 2016 06:45:57 +0000 Subject: [PATCH] ddk: v.4.4.5 git-svn-id: svn://kolibrios.org@6336 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/ddk/Makefile | 1 + drivers/ddk/linux/kmap.c | 96 +++++++++++++++++++++++++ drivers/ddk/linux/workqueue.c | 2 +- drivers/include/asm-generic/delay.h | 3 - drivers/include/display.h | 5 ++ drivers/include/drm/drmP.h | 5 ++ drivers/include/drm/drm_cache.h | 9 +++ drivers/include/drm/drm_dp_mst_helper.h | 27 +++---- drivers/include/drm/drm_fixed.h | 53 +++++++++++++- drivers/include/linux/backlight.h | 4 ++ drivers/include/linux/dmi.h | 2 + drivers/include/linux/file.h | 1 + drivers/include/linux/idr.h | 1 - drivers/include/linux/lockdep.h | 2 +- drivers/include/linux/mmdebug.h | 1 + drivers/include/linux/rcutiny.h | 4 ++ drivers/include/linux/sfi.h | 2 +- drivers/include/syscall.h | 2 +- 18 files changed, 193 insertions(+), 27 deletions(-) create mode 100644 drivers/ddk/linux/kmap.c diff --git a/drivers/ddk/Makefile b/drivers/ddk/Makefile index faa15d8016..64a1a15932 100644 --- a/drivers/ddk/Makefile +++ b/drivers/ddk/Makefile @@ -44,6 +44,7 @@ NAME_SRCS:= \ linux/idr.c \ linux/interval_tree.c \ linux/kasprintf.c \ + linux/kmap.c \ linux/list_sort.c \ linux/mutex.c \ linux/rbtree.c \ diff --git a/drivers/ddk/linux/kmap.c b/drivers/ddk/linux/kmap.c new file mode 100644 index 0000000000..a5ba2b7ff3 --- /dev/null +++ b/drivers/ddk/linux/kmap.c @@ -0,0 +1,96 @@ +#include +#include +#include + +#define KMAP_MAX 256 + +static struct mutex kmap_mutex; +static struct page* kmap_table[KMAP_MAX]; +static int kmap_av; +static int kmap_first; +static void* kmap_base; + +int kmap_init() +{ + kmap_base = AllocKernelSpace(KMAP_MAX*4096); + if(kmap_base == NULL) + return -1; + + kmap_av = KMAP_MAX; + MutexInit(&kmap_mutex); + return 0; +}; + +void *kmap(struct page *page) +{ + void *vaddr = NULL; + int i; + + do + { + MutexLock(&kmap_mutex); + if(kmap_av != 0) + { + for(i = kmap_first; i < KMAP_MAX; i++) + { + if(kmap_table[i] == NULL) + { + kmap_av--; + kmap_first = i; + kmap_table[i] = page; + vaddr = kmap_base + (i<<12); + MapPage(vaddr,(addr_t)page,3); + break; + }; + }; + }; + MutexUnlock(&kmap_mutex); + }while(vaddr == NULL); + + return vaddr; +}; + +void *kmap_atomic(struct page *page) __attribute__ ((alias ("kmap"))); + +void kunmap(struct page *page) +{ + void *vaddr; + int i; + + MutexLock(&kmap_mutex); + + for(i = 0; i < KMAP_MAX; i++) + { + if(kmap_table[i] == page) + { + kmap_av++; + if(i < kmap_first) + kmap_first = i; + kmap_table[i] = NULL; + vaddr = kmap_base + (i<<12); + MapPage(vaddr,0,0); + break; + }; + }; + + MutexUnlock(&kmap_mutex); +}; + +void kunmap_atomic(void *vaddr) +{ + int i; + + MapPage(vaddr,0,0); + + i = (vaddr - kmap_base) >> 12; + + MutexLock(&kmap_mutex); + + kmap_av++; + if(i < kmap_first) + kmap_first = i; + kmap_table[i] = NULL; + + MutexUnlock(&kmap_mutex); +} + diff --git a/drivers/ddk/linux/workqueue.c b/drivers/ddk/linux/workqueue.c index f7387d0600..8a615c0644 100644 --- a/drivers/ddk/linux/workqueue.c +++ b/drivers/ddk/linux/workqueue.c @@ -195,7 +195,7 @@ int mod_timer(struct timer_list *timer, unsigned long expires) ret = 1; }; - timer->handle = TimerHS(expires, 0, timer->function, timer->data); + timer->handle = TimerHS(expires, 0, timer->function, (void*)timer->data); return ret; } diff --git a/drivers/include/asm-generic/delay.h b/drivers/include/asm-generic/delay.h index 0f79054ce7..0762da6929 100644 --- a/drivers/include/asm-generic/delay.h +++ b/drivers/include/asm-generic/delay.h @@ -19,9 +19,6 @@ extern void __delay(unsigned long loops); #define udelay(n) \ ({ \ if (__builtin_constant_p(n)) { \ - if ((n) / 20000 >= 1) \ - __bad_udelay(); \ - else \ __const_udelay((n) * 0x10c7ul); \ } else { \ __udelay(n); \ diff --git a/drivers/include/display.h b/drivers/include/display.h index 896cdf6c19..5b7510dfa8 100644 --- a/drivers/include/display.h +++ b/drivers/include/display.h @@ -40,6 +40,11 @@ struct kos_framebuffer uint32_t pde[8]; }; +int fake_framebuffer_create(); +void set_fake_framebuffer(); +int kolibri_framebuffer_init(void *param); +void kolibri_framebuffer_update(struct drm_device *dev, struct kos_framebuffer *kfb); + struct tag_display { u32 x; diff --git a/drivers/include/drm/drmP.h b/drivers/include/drm/drmP.h index 194d458053..8154209e5d 100644 --- a/drivers/include/drm/drmP.h +++ b/drivers/include/drm/drmP.h @@ -318,6 +318,11 @@ struct drm_file { unsigned universal_planes:1; /* true if client understands atomic properties */ unsigned atomic:1; + /* + * This client is allowed to gain master privileges for @master. + * Protected by struct drm_device::master_mutex. + */ + unsigned allowed_master:1; struct list_head lhead; struct drm_minor *minor; unsigned long lock_count; diff --git a/drivers/include/drm/drm_cache.h b/drivers/include/drm/drm_cache.h index 7bfb063029..461a0558bc 100644 --- a/drivers/include/drm/drm_cache.h +++ b/drivers/include/drm/drm_cache.h @@ -35,4 +35,13 @@ void drm_clflush_pages(struct page *pages[], unsigned long num_pages); +static inline bool drm_arch_can_wc_memory(void) +{ +#if defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) + return false; +#else + return true; +#endif +} + #endif diff --git a/drivers/include/drm/drm_dp_mst_helper.h b/drivers/include/drm/drm_dp_mst_helper.h index 5340099741..f356f97164 100644 --- a/drivers/include/drm/drm_dp_mst_helper.h +++ b/drivers/include/drm/drm_dp_mst_helper.h @@ -44,8 +44,6 @@ struct drm_dp_vcpi { /** * struct drm_dp_mst_port - MST port * @kref: reference count for this port. - * @guid_valid: for DP 1.2 devices if we have validated the GUID. - * @guid: guid for DP 1.2 device on this port. * @port_num: port number * @input: if this port is an input port. * @mcs: message capability status - DP 1.2 spec. @@ -70,10 +68,6 @@ struct drm_dp_vcpi { struct drm_dp_mst_port { struct kref kref; - /* if dpcd 1.2 device is on this port - its GUID info */ - bool guid_valid; - u8 guid[16]; - u8 port_num; bool input; bool mcs; @@ -109,10 +103,12 @@ struct drm_dp_mst_port { * @tx_slots: transmission slots for this device. * @last_seqno: last sequence number used to talk to this. * @link_address_sent: if a link address message has been sent to this device yet. + * @guid: guid for DP 1.2 branch device. port under this branch can be + * identified by port #. * * This structure represents an MST branch device, there is one - * primary branch device at the root, along with any others connected - * to downstream ports + * primary branch device at the root, along with any other branches connected + * to downstream port of parent branches. */ struct drm_dp_mst_branch { struct kref kref; @@ -131,6 +127,9 @@ struct drm_dp_mst_branch { struct drm_dp_sideband_msg_tx *tx_slots[2]; int last_seqno; bool link_address_sent; + + /* global unique identifier to identify branch devices */ + u8 guid[16]; }; @@ -405,11 +404,9 @@ struct drm_dp_payload { * @conn_base_id: DRM connector ID this mgr is connected to. * @down_rep_recv: msg receiver state for down replies. * @up_req_recv: msg receiver state for up requests. - * @lock: protects mst state, primary, guid, dpcd. + * @lock: protects mst state, primary, dpcd. * @mst_state: if this manager is enabled for an MST capable port. * @mst_primary: pointer to the primary branch device. - * @guid_valid: GUID valid for the primary branch device. - * @guid: GUID for primary port. * @dpcd: cache of DPCD for primary port. * @pbn_div: PBN to slots divisor. * @@ -431,13 +428,11 @@ struct drm_dp_mst_topology_mgr { struct drm_dp_sideband_msg_rx up_req_recv; /* pointer to info about the initial MST device */ - struct mutex lock; /* protects mst_state + primary + guid + dpcd */ + struct mutex lock; /* protects mst_state + primary + dpcd */ bool mst_state; struct drm_dp_mst_branch *mst_primary; - /* primary MST device GUID */ - bool guid_valid; - u8 guid[16]; + u8 dpcd[DP_RECEIVER_CAP_SIZE]; u8 sink_count; int pbn_div; @@ -450,9 +445,7 @@ struct drm_dp_mst_topology_mgr { the mstb tx_slots and txmsg->state once they are queued */ struct mutex qlock; struct list_head tx_msg_downq; - struct list_head tx_msg_upq; bool tx_down_in_progress; - bool tx_up_in_progress; /* payload info + lock for it */ struct mutex payload_lock; diff --git a/drivers/include/drm/drm_fixed.h b/drivers/include/drm/drm_fixed.h index d639049a61..553210c02e 100644 --- a/drivers/include/drm/drm_fixed.h +++ b/drivers/include/drm/drm_fixed.h @@ -73,18 +73,28 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B) #define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT) #define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1) #define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK) +#define DRM_FIXED_EPSILON 1LL +#define DRM_FIXED_ALMOST_ONE (DRM_FIXED_ONE - DRM_FIXED_EPSILON) static inline s64 drm_int2fixp(int a) { return ((s64)a) << DRM_FIXED_POINT; } -static inline int drm_fixp2int(int64_t a) +static inline int drm_fixp2int(s64 a) { return ((s64)a) >> DRM_FIXED_POINT; } -static inline unsigned drm_fixp_msbset(int64_t a) +static inline int drm_fixp2int_ceil(s64 a) +{ + if (a > 0) + return drm_fixp2int(a + DRM_FIXED_ALMOST_ONE); + else + return drm_fixp2int(a - DRM_FIXED_ALMOST_ONE); +} + +static inline unsigned drm_fixp_msbset(s64 a) { unsigned shift, sign = (a >> 63) & 1; @@ -136,6 +146,45 @@ static inline s64 drm_fixp_div(s64 a, s64 b) return result; } +static inline s64 drm_fixp_from_fraction(s64 a, s64 b) +{ + s64 res; + bool a_neg = a < 0; + bool b_neg = b < 0; + u64 a_abs = a_neg ? -a : a; + u64 b_abs = b_neg ? -b : b; + u64 rem; + + /* determine integer part */ + u64 res_abs = div64_u64_rem(a_abs, b_abs, &rem); + + /* determine fractional part */ + { + u32 i = DRM_FIXED_POINT; + + do { + rem <<= 1; + res_abs <<= 1; + if (rem >= b_abs) { + res_abs |= 1; + rem -= b_abs; + } + } while (--i != 0); + } + + /* round up LSB */ + { + u64 summand = (rem << 1) >= b_abs; + + res_abs += summand; + } + + res = (s64) res_abs; + if (a_neg ^ b_neg) + res = -res; + return res; +} + static inline s64 drm_fixp_exp(s64 x) { s64 tolerance = div64_s64(DRM_FIXED_ONE, 1000000); diff --git a/drivers/include/linux/backlight.h b/drivers/include/linux/backlight.h index a9a85aa766..b4938224fb 100644 --- a/drivers/include/linux/backlight.h +++ b/drivers/include/linux/backlight.h @@ -7,6 +7,10 @@ #ifndef _LINUX_BACKLIGHT_H #define _LINUX_BACKLIGHT_H + +#include +#include +#include /* Notes on locking: * * backlight_device->ops_lock is an internal backlight lock protecting the diff --git a/drivers/include/linux/dmi.h b/drivers/include/linux/dmi.h index 919deb6cdb..5055ac3414 100644 --- a/drivers/include/linux/dmi.h +++ b/drivers/include/linux/dmi.h @@ -2,6 +2,7 @@ #define __DMI_H__ #include +#include #include /* enum dmi_field is in mod_devicetable.h */ @@ -93,6 +94,7 @@ struct dmi_dev_onboard { int devfn; }; +extern struct kobject *dmi_kobj; extern int dmi_check_system(const struct dmi_system_id *list); const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list); extern const char * dmi_get_system_info(int field); diff --git a/drivers/include/linux/file.h b/drivers/include/linux/file.h index 3cda365f66..452c93e4f0 100644 --- a/drivers/include/linux/file.h +++ b/drivers/include/linux/file.h @@ -10,6 +10,7 @@ #include struct file; + extern void fput(struct file *); extern struct file *fget(unsigned int fd); #endif /* __LINUX_FILE_H */ diff --git a/drivers/include/linux/idr.h b/drivers/include/linux/idr.h index ba8732e7ed..94c671d43b 100644 --- a/drivers/include/linux/idr.h +++ b/drivers/include/linux/idr.h @@ -12,7 +12,6 @@ #ifndef __IDR_H__ #define __IDR_H__ -#include #include #include #include diff --git a/drivers/include/linux/lockdep.h b/drivers/include/linux/lockdep.h index 598780ca8d..4b5a15b331 100644 --- a/drivers/include/linux/lockdep.h +++ b/drivers/include/linux/lockdep.h @@ -2,7 +2,7 @@ * Runtime locking correctness validator * * Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar - * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra + * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra * * see Documentation/locking/lockdep-design.txt for more details. */ diff --git a/drivers/include/linux/mmdebug.h b/drivers/include/linux/mmdebug.h index 877ef226f9..772362adf4 100644 --- a/drivers/include/linux/mmdebug.h +++ b/drivers/include/linux/mmdebug.h @@ -1,6 +1,7 @@ #ifndef LINUX_MM_DEBUG_H #define LINUX_MM_DEBUG_H 1 +#include #include struct page; diff --git a/drivers/include/linux/rcutiny.h b/drivers/include/linux/rcutiny.h index 3df6c1ec4e..2d75a23779 100644 --- a/drivers/include/linux/rcutiny.h +++ b/drivers/include/linux/rcutiny.h @@ -37,6 +37,10 @@ static inline void cond_synchronize_rcu(unsigned long oldstate) might_sleep(); } +static inline unsigned long get_state_synchronize_sched(void) +{ + return 0; +} static inline void rcu_barrier_bh(void) { wait_rcu_gp(call_rcu_bh); diff --git a/drivers/include/linux/sfi.h b/drivers/include/linux/sfi.h index 9a6c99903c..d9b436f099 100644 --- a/drivers/include/linux/sfi.h +++ b/drivers/include/linux/sfi.h @@ -59,7 +59,7 @@ #ifndef _LINUX_SFI_H #define _LINUX_SFI_H -//#include +#include #include /* Table signatures reserved by the SFI specification */ diff --git a/drivers/include/syscall.h b/drivers/include/syscall.h index 7aabfd8633..9eb7e650ed 100644 --- a/drivers/include/syscall.h +++ b/drivers/include/syscall.h @@ -486,7 +486,7 @@ static inline void sysSetScreen(int width, int height, int pitch) ("" :::"eax","ecx","edx"); } -int drm_order(unsigned long size); +void FASTCALL sysSetFramebuffer(void *fb)__asm__("SetFramebuffer"); static inline void __iomem *ioremap(u32 offset, size_t size) {