Merge branch 'drm-nouveau-next' of git://git.freedesktop.org/git/nouveau/linux-2...
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / nouveau / nouveau_display.c
index 795a9e3c990a0cba3599b5c754f33adf8e15da93..a85e112863d1ae2062bdd7e4ea52fe9c4967bf27 100644 (file)
@@ -155,20 +155,20 @@ static const struct drm_mode_config_funcs nouveau_mode_config_funcs = {
 };
 
 
-struct drm_prop_enum_list {
+struct nouveau_drm_prop_enum_list {
        u8 gen_mask;
        int type;
        char *name;
 };
 
-static struct drm_prop_enum_list underscan[] = {
+static struct nouveau_drm_prop_enum_list underscan[] = {
        { 6, UNDERSCAN_AUTO, "auto" },
        { 6, UNDERSCAN_OFF, "off" },
        { 6, UNDERSCAN_ON, "on" },
        {}
 };
 
-static struct drm_prop_enum_list dither_mode[] = {
+static struct nouveau_drm_prop_enum_list dither_mode[] = {
        { 7, DITHERING_MODE_AUTO, "auto" },
        { 7, DITHERING_MODE_OFF, "off" },
        { 1, DITHERING_MODE_ON, "on" },
@@ -178,7 +178,7 @@ static struct drm_prop_enum_list dither_mode[] = {
        {}
 };
 
-static struct drm_prop_enum_list dither_depth[] = {
+static struct nouveau_drm_prop_enum_list dither_depth[] = {
        { 6, DITHERING_DEPTH_AUTO, "auto" },
        { 6, DITHERING_DEPTH_6BPC, "6 bpc" },
        { 6, DITHERING_DEPTH_8BPC, "8 bpc" },
@@ -186,7 +186,7 @@ static struct drm_prop_enum_list dither_depth[] = {
 };
 
 #define PROP_ENUM(p,gen,n,list) do {                                           \
-       struct drm_prop_enum_list *l = (list);                                 \
+       struct nouveau_drm_prop_enum_list *l = (list);                         \
        int c = 0;                                                             \
        while (l->gen_mask) {                                                  \
                if (l->gen_mask & (1 << (gen)))                                \
@@ -281,16 +281,24 @@ nouveau_display_create(struct drm_device *dev)
        PROP_ENUM(disp->underscan_property, gen, "underscan", underscan);
 
        disp->underscan_hborder_property =
-               drm_property_create(dev, DRM_MODE_PROP_RANGE,
-                                   "underscan hborder", 2);
-       disp->underscan_hborder_property->values[0] = 0;
-       disp->underscan_hborder_property->values[1] = 128;
+               drm_property_create_range(dev, 0, "underscan hborder", 0, 128);
 
        disp->underscan_vborder_property =
-               drm_property_create(dev, DRM_MODE_PROP_RANGE,
-                                   "underscan vborder", 2);
-       disp->underscan_vborder_property->values[0] = 0;
-       disp->underscan_vborder_property->values[1] = 128;
+               drm_property_create_range(dev, 0, "underscan vborder", 0, 128);
+
+       if (gen == 1) {
+               disp->vibrant_hue_property =
+                       drm_property_create(dev, DRM_MODE_PROP_RANGE,
+                                           "vibrant hue", 2);
+               disp->vibrant_hue_property->values[0] = 0;
+               disp->vibrant_hue_property->values[1] = 180; /* -90..+90 */
+
+               disp->color_vibrance_property =
+                       drm_property_create(dev, DRM_MODE_PROP_RANGE,
+                                           "color vibrance", 2);
+               disp->color_vibrance_property->values[0] = 0;
+               disp->color_vibrance_property->values[1] = 200; /* -100..+100 */
+       }
 
        dev->mode_config.funcs = (void *)&nouveau_mode_config_funcs;
        dev->mode_config.fb_base = pci_resource_start(dev->pdev, 1);
@@ -309,6 +317,9 @@ nouveau_display_create(struct drm_device *dev)
                dev->mode_config.max_height = 8192;
        }
 
+       dev->mode_config.preferred_depth = 24;
+       dev->mode_config.prefer_shadow = 1;
+
        drm_kms_helper_poll_init(dev);
        drm_kms_helper_poll_disable(dev);
 
@@ -430,15 +441,19 @@ nouveau_page_flip_emit(struct nouveau_channel *chan,
                goto fail;
 
        /* Emit the pageflip */
-       ret = RING_SPACE(chan, 2);
+       ret = RING_SPACE(chan, 3);
        if (ret)
                goto fail;
 
-       if (dev_priv->card_type < NV_C0)
+       if (dev_priv->card_type < NV_C0) {
                BEGIN_RING(chan, NvSubSw, NV_SW_PAGE_FLIP, 1);
-       else
-               BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0500, 1);
-       OUT_RING  (chan, 0);
+               OUT_RING  (chan, 0x00000000);
+               OUT_RING  (chan, 0x00000000);
+       } else {
+               BEGIN_NVC0(chan, 2, 0, NV10_SUBCHAN_REF_CNT, 1);
+               OUT_RING  (chan, ++chan->fence.sequence);
+               BEGIN_NVC0(chan, 8, 0, NVSW_SUBCHAN_PAGE_FLIP, 0x0000);
+       }
        FIRE_RING (chan);
 
        ret = nouveau_fence_new(chan, pfence, true);