From 5d98dda3cf7a88ef64126fb06a35412689c9fbaf Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 27 Jan 2016 05:47:59 +0000 Subject: [PATCH] i915-4.4 update git-svn-id: svn://kolibrios.org@6103 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/video/drm/drm_dp_helper.c | 2 +- drivers/video/drm/i915/i915_dma.c | 2 +- drivers/video/drm/i915/i915_drv.h | 10 +-- drivers/video/drm/i915/i915_gem.c | 2 +- drivers/video/drm/i915/i915_irq.c | 1 + drivers/video/drm/i915/intel_dp.c | 11 ++++ drivers/video/drm/i915/intel_opregion.c | 2 - drivers/video/drm/i915/intel_sdvo.c | 8 +++ drivers/video/drm/i915/intel_sprite.c | 31 +++++---- drivers/video/drm/i915/kms_display.c | 84 ++++++++++++++++++------- drivers/video/drm/i915/main.c | 45 +++++-------- drivers/video/drm/i915/utils.c | 28 --------- 12 files changed, 124 insertions(+), 102 deletions(-) diff --git a/drivers/video/drm/drm_dp_helper.c b/drivers/video/drm/drm_dp_helper.c index 4b825c3f8b..cf89607093 100644 --- a/drivers/video/drm/drm_dp_helper.c +++ b/drivers/video/drm/drm_dp_helper.c @@ -22,7 +22,7 @@ #include #include -//#include +#include #include #include #include diff --git a/drivers/video/drm/i915/i915_dma.c b/drivers/video/drm/i915/i915_dma.c index 66f263a4f8..fc6427434f 100644 --- a/drivers/video/drm/i915/i915_dma.c +++ b/drivers/video/drm/i915/i915_dma.c @@ -44,7 +44,7 @@ //#include //#include #include -//#include +#include #include void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen); diff --git a/drivers/video/drm/i915/i915_drv.h b/drivers/video/drm/i915/i915_drv.h index f4e7bf639f..d92b8a6c60 100644 --- a/drivers/video/drm/i915/i915_drv.h +++ b/drivers/video/drm/i915/i915_drv.h @@ -2691,10 +2691,10 @@ struct i915_params { bool verbose_state_checks; bool nuclear_pageflip; int edp_vswing; - /* Kolibri related */ - int fbsize; - char *log_file; - char *cmdline_mode; + /* Kolibri related */ + int fbsize; + char *log_file; + char *cmdline_mode; }; extern struct i915_params i915 __read_mostly; @@ -3540,7 +3540,7 @@ wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms) if (time_after(target_jiffies, tmp_jiffies)) { remaining_jiffies = target_jiffies - tmp_jiffies; - delay(remaining_jiffies); + delay(remaining_jiffies); } } diff --git a/drivers/video/drm/i915/i915_gem.c b/drivers/video/drm/i915/i915_gem.c index 4010e50e13..d330bcd3ab 100644 --- a/drivers/video/drm/i915/i915_gem.c +++ b/drivers/video/drm/i915/i915_gem.c @@ -1055,7 +1055,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, wait.evnt = CreateEvent(NULL, MANUAL_DESTROY); for (;;) { - unsigned long flags; + unsigned long flags; /* We need to check whether any gpu reset happened in between * the caller grabbing the seqno and now ... */ diff --git a/drivers/video/drm/i915/i915_irq.c b/drivers/video/drm/i915/i915_irq.c index 3e7a2ecf51..87e9337f35 100644 --- a/drivers/video/drm/i915/i915_irq.c +++ b/drivers/video/drm/i915/i915_irq.c @@ -28,6 +28,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include diff --git a/drivers/video/drm/i915/intel_dp.c b/drivers/video/drm/i915/intel_dp.c index 65236b4276..c86ef78d6c 100644 --- a/drivers/video/drm/i915/intel_dp.c +++ b/drivers/video/drm/i915/intel_dp.c @@ -1085,6 +1085,14 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector) name, ret); return; } + + ret = sysfs_create_link(&connector->base.kdev->kobj, + &intel_dp->aux.ddc.dev.kobj, + intel_dp->aux.ddc.dev.kobj.name); + if (ret < 0) { + DRM_ERROR("sysfs_create_link() for %s failed (%d)\n", name, ret); + drm_dp_aux_unregister(&intel_dp->aux); + } } static void @@ -1092,6 +1100,9 @@ intel_dp_connector_unregister(struct intel_connector *intel_connector) { struct intel_dp *intel_dp = intel_attached_dp(&intel_connector->base); + if (!intel_connector->mst_port) + sysfs_remove_link(&intel_connector->base.kdev->kobj, + intel_dp->aux.ddc.dev.kobj.name); intel_connector_unregister(intel_connector); } diff --git a/drivers/video/drm/i915/intel_opregion.c b/drivers/video/drm/i915/intel_opregion.c index b0992135cd..3f1510139f 100644 --- a/drivers/video/drm/i915/intel_opregion.c +++ b/drivers/video/drm/i915/intel_opregion.c @@ -25,8 +25,6 @@ * */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include diff --git a/drivers/video/drm/i915/intel_sdvo.c b/drivers/video/drm/i915/intel_sdvo.c index 12c645e3e7..44e5fd2646 100644 --- a/drivers/video/drm/i915/intel_sdvo.c +++ b/drivers/video/drm/i915/intel_sdvo.c @@ -2347,6 +2347,8 @@ intel_sdvo_connector_unregister(struct intel_connector *intel_connector) drm_connector = &intel_connector->base; sdvo_encoder = intel_attached_sdvo(&intel_connector->base); + sysfs_remove_link(&drm_connector->kdev->kobj, + sdvo_encoder->ddc.dev.kobj.name); intel_connector_unregister(intel_connector); } @@ -2379,6 +2381,12 @@ intel_sdvo_connector_init(struct intel_sdvo_connector *connector, if (ret < 0) goto err1; + ret = sysfs_create_link(&drm_connector->kdev->kobj, + &encoder->ddc.dev.kobj, + encoder->ddc.dev.kobj.name); + if (ret < 0) + goto err2; + return 0; err2: diff --git a/drivers/video/drm/i915/intel_sprite.c b/drivers/video/drm/i915/intel_sprite.c index 634b1aa03c..11495a8d15 100644 --- a/drivers/video/drm/i915/intel_sprite.c +++ b/drivers/video/drm/i915/intel_sprite.c @@ -85,9 +85,8 @@ void intel_pipe_update_start(struct intel_crtc *crtc) enum pipe pipe = crtc->pipe; long timeout = msecs_to_jiffies_timeout(1); int scanline, min, max, vblank_start; -#if 0 -// wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base); -// DEFINE_WAIT(wait); + wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base); + DEFINE_WAIT(wait); vblank_start = adjusted_mode->crtc_vblank_start; if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) @@ -97,11 +96,13 @@ void intel_pipe_update_start(struct intel_crtc *crtc) min = vblank_start - usecs_to_scanlines(adjusted_mode, 100); max = vblank_start - 1; + local_irq_disable(); + if (min <= 0 || max <= 0) return; -// if (WARN_ON(drm_vblank_get(dev, pipe))) -// return false; + if (WARN_ON(drm_crtc_vblank_get(&crtc->base))) + return; crtc->debug.min_vbl = min; crtc->debug.max_vbl = max; @@ -125,15 +126,21 @@ void intel_pipe_update_start(struct intel_crtc *crtc) break; } -// local_irq_enable(); - - schedule_timeout(timeout); - timeout = 0; -// local_irq_disable(); + local_irq_enable(); + + { + unsigned long expire; + expire = timeout + jiffies; + WaitEventTimeout(wait.evnt, timeout);; + timeout = expire - jiffies; + timeout = timeout < 0 ? 0 : timeout; + } + local_irq_disable(); } finish_wait(wq, &wait); -#endif + + drm_crtc_vblank_put(&crtc->base); crtc->debug.scanline_start = scanline; crtc->debug.start_vbl_time = ktime_get(); @@ -162,7 +169,7 @@ void intel_pipe_update_end(struct intel_crtc *crtc) trace_i915_pipe_update_end(crtc, end_vbl_count, scanline_end); -// local_irq_enable(); + local_irq_enable(); if (crtc->debug.start_vbl_count && crtc->debug.start_vbl_count != end_vbl_count) { diff --git a/drivers/video/drm/i915/kms_display.c b/drivers/video/drm/i915/kms_display.c index 1243c519b1..1b29ccff7f 100644 --- a/drivers/video/drm/i915/kms_display.c +++ b/drivers/video/drm/i915/kms_display.c @@ -74,8 +74,6 @@ static int set_mode(struct drm_device *dev, struct drm_connector *connector, int stride; int ret; -ENTER(); - drm_modeset_lock_all(dev); list_for_each_entry(tmpc, &dev->mode_config.connector_list, head) @@ -206,8 +204,6 @@ do_set: drm_modeset_unlock_all(dev); -LEAVE(); - return ret; } @@ -223,8 +219,6 @@ static int set_mode_ex(struct drm_device *dev, int stride; int ret; -ENTER(); - drm_modeset_lock_all(dev); list_for_each_entry(tmpc, &dev->mode_config.connector_list, head) @@ -322,8 +316,6 @@ ENTER(); drm_modeset_unlock_all(dev); -LEAVE(); - return ret; } @@ -422,10 +414,7 @@ static struct drm_connector* get_cmdline_connector(struct drm_device *dev, const static int choose_config(struct drm_device *dev, struct drm_connector **boot_connector, struct drm_crtc **boot_crtc) { - const struct drm_connector_helper_funcs *connector_funcs; - struct drm_connector *connector = NULL; - struct drm_encoder *encoder = NULL; - struct drm_crtc *crtc = NULL; + struct drm_connector *connector; if((i915.cmdline_mode != NULL) && (*i915.cmdline_mode != 0)) { @@ -451,6 +440,7 @@ static int choose_config(struct drm_device *dev, struct drm_connector **boot_con return -ENOENT; }; + static int get_boot_mode(struct drm_connector *connector, videomode_t *usermode) { struct drm_display_mode *mode; @@ -481,8 +471,6 @@ int init_display_kms(struct drm_device *dev, videomode_t *usermode) u32 ifl; int ret; -ENTER(); - mutex_lock(&dev->mode_config.mutex); ret = choose_config(dev, &connector, &crtc); if(ret) @@ -571,8 +559,6 @@ ENTER(); err = init_bitmaps(); #endif - LEAVE(); - return ret; }; @@ -581,13 +567,12 @@ int set_cmdline_mode_ext(struct drm_device *dev, const char *cmdline) { struct drm_connector_helper_funcs *connector_funcs; struct drm_connector *connector; - struct drm_cmdline_mode cmd_mode; + struct drm_cmdline_mode cmd_mode = {0}; struct drm_display_mode *mode; char *mode_option; int retval = 0; char con_edid[128]; -ENTER(); if((cmdline == NULL) || (*cmdline == 0)) return EINVAL; @@ -604,8 +589,6 @@ ENTER(); mode_option++; - __builtin_memset(&cmd_mode, 0, sizeof(cmd_mode)); - if( !drm_mode_parse_command_line_for_connector(mode_option, connector, &cmd_mode)) return EINVAL; @@ -633,10 +616,69 @@ ENTER(); drm_mode_destroy(dev, mode); -LEAVE(); return retval; } +void list_connectors(struct drm_device *dev) +{ + struct drm_connector *connector; + char con_edid[128]; + + mutex_lock(&dev->mode_config.mutex); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) + { + if( connector->status != connector_status_connected) + continue; + + memcpy(con_edid, connector->edid_blob_ptr->data, 128); + + if(connector == os_display->connector) + { + printf("%s mode %dx%d connected %s model %x serial number %u\n", + connector->name, os_display->width, os_display->height, + manufacturer_name(con_edid + 0x08), + (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)), + (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8) + + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24))); + continue; + } + else + { + printf("%s connected: %s model %x serial number %u\n", + connector->name, manufacturer_name(con_edid + 0x08), + (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)), + (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8) + + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24))); + } + }; + mutex_unlock(&dev->mode_config.mutex); +} + +int list_connector_modes(struct drm_device *dev, const char* name) +{ + struct drm_connector *connector; + struct drm_display_mode *drmmode; + + mutex_lock(&dev->mode_config.mutex); + + connector = get_cmdline_connector(dev, name); + if(connector == NULL) + { + mutex_unlock(&dev->mode_config.mutex); + return EINVAL; + }; + + printf("connector %s probed modes :\n", connector->name); + + list_for_each_entry(drmmode, &connector->modes, head) + { + printf("%dx%d@%d\n", drmmode->hdisplay, drmmode->vdisplay, drm_mode_vrefresh(drmmode)); + }; + + mutex_unlock(&dev->mode_config.mutex); + return 0; +}; + int get_videomodes(videomode_t *mode, int *count) { int err = -1; diff --git a/drivers/video/drm/i915/main.c b/drivers/video/drm/i915/main.c index 750bedc0ec..394b808399 100644 --- a/drivers/video/drm/i915/main.c +++ b/drivers/video/drm/i915/main.c @@ -277,6 +277,7 @@ int do_command_line(const char* usercmd) char *cmdline; int argc, i, c; char **argv; + int retval = 0; if( (usercmd == NULL) || (*usercmd == 0) ) return 1; @@ -295,7 +296,9 @@ int do_command_line(const char* usercmd) { static struct option long_options[] = { - {"video", required_argument, 0, 'v'}, + {"list-connectors", no_argument, 0, OPTION_CONNECTORS}, + {"list-connector-modes", required_argument, 0, OPTION_CONN_MODES}, + {"video", required_argument, 0, 'v'}, {0, 0, 0, 0} }; @@ -311,14 +314,22 @@ int do_command_line(const char* usercmd) { case 'v': printf("cmdline_mode %s\n",optarg); - set_cmdline_mode_ext(main_device, optarg); + retval = set_cmdline_mode_ext(main_device, optarg); + break; + + case OPTION_CONNECTORS: + list_connectors(main_device); + break; + + case OPTION_CONN_MODES: + retval = list_connector_modes(main_device, optarg); break; } } __builtin_free(argv); __builtin_free(cmdline); - return 0; + return retval; }; #define CURRENT_API 0x0200 /* 2.00 */ @@ -856,31 +867,3 @@ static char* parse_mode(char *p, videomode_t *mode) return p; }; -#include - -u64 long_div(u64 dividend, u64 divisor) -{ -#if 1 - u32 high = divisor >> 32; - u64 quot; - - if (high == 0) { - quot = div_u64(dividend, divisor); - } else { - int n = 1 + fls(high); - quot = div_u64(dividend >> n, divisor >> n); - - if (quot != 0) - quot--; - if ((dividend - quot * divisor) >= divisor) - quot++; - } - - return quot; -#endif -// return dividend / divisor; -}; - - - - diff --git a/drivers/video/drm/i915/utils.c b/drivers/video/drm/i915/utils.c index b18c413068..a241f1c93d 100644 --- a/drivers/video/drm/i915/utils.c +++ b/drivers/video/drm/i915/utils.c @@ -973,34 +973,6 @@ int split_cmdline(char *cmdline, char **argv) return argc; }; -char *strstr(const char *cs, const char *ct) -{ -int d0, d1; -register char *__res; -__asm__ __volatile__( - "movl %6,%%edi\n\t" - "repne\n\t" - "scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%edx\n" - "1:\tmovl %6,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%edx,%%ecx\n\t" - "repe\n\t" - "cmpsb\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpb $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:" - : "=a" (__res), "=&c" (d0), "=&S" (d1) - : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct) - : "dx", "di"); -return __res; -} fb_get_options(const char *name, char **option) {