drm/nouveau/disp/g84-: port OR HDMI control to nvkm_ior
authorBen Skeggs <bskeggs@redhat.com>
Fri, 19 May 2017 13:59:35 +0000 (23:59 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 16 Jun 2017 04:04:54 +0000 (14:04 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
29 files changed:
drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmi.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorg84.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgk104.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm107.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgt215.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sormcp77.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sormcp89.c

index 3e110108272c8e660f1948d98a653347a5995d29..50fbe1cb6653d73f999a7a14456c108a3e153008 100644 (file)
@@ -39,9 +39,7 @@ g84_disp = {
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
        .dac = { .nr = 3, .new = nv50_dac_new },
-       .sor.nr = 2,
-       .sor.new = g84_sor_new,
-       .sor.hdmi = g84_hdmi_ctrl,
+       .sor = { .nr = 2, .new = g84_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index ac9cd335e4f3fe29136222fd495ad9f25dd83a67..8cc2a8c03fc613172fde1b34149320679fffce84 100644 (file)
@@ -40,9 +40,7 @@ g94_disp = {
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
        .dac = { .nr = 3, .new = nv50_dac_new },
-       .sor.nr = 4,
-       .sor.new = g94_sor_new,
-       .sor.hdmi = g84_hdmi_ctrl,
+       .sor = { .nr = 4, .new = g94_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 76972e009f365c52a5db5da24cb9ae1b0b062821..d4df1983f7696545413b9e37a7ca12878c136f94 100644 (file)
@@ -510,7 +510,6 @@ gf119_disp = {
        .sor.nr = 4,
        .sor.new = gf119_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gf119_hdmi_ctrl,
 };
 
 int
index 2f84b1b5a4698b5331fbc69ae31607d04c5c84b5..4d22d87c46200e35d4dda86f9e42fed41f57198b 100644 (file)
@@ -42,7 +42,6 @@ gk104_disp = {
        .sor.nr = 4,
        .sor.new = gk104_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gk104_hdmi_ctrl,
 };
 
 int
index abf50b20b88c26d10d04005616c5ae4148504b6b..adc2a2257438cfaee833eef7142ee29eee13460b 100644 (file)
@@ -42,7 +42,6 @@ gk110_disp = {
        .sor.nr = 4,
        .sor.new = gk104_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gk104_hdmi_ctrl,
 };
 
 int
index 0923ca4b42b6f80a0ff9c0cae7747ad7e05ee5e3..116b99b513599e9777ea1049797e7524eee9d457 100644 (file)
@@ -42,7 +42,6 @@ gm107_disp = {
        .sor.nr = 4,
        .sor.new = gm107_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gk104_hdmi_ctrl,
 };
 
 int
index cc83734e321be279ed1b2dd199dde667f3ede34c..ffdb5a412821538a5b0d67849bf4ce9d2773363a 100644 (file)
@@ -42,7 +42,6 @@ gm200_disp = {
        .sor.nr = 4,
        .sor.new = gm200_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gk104_hdmi_ctrl,
        .sor.magic = gm200_sor_magic,
 };
 
index 4b6a60d646ccc6a90b3827a0c79c595e78b0759b..bd5ab596877bf2a7a6a42ca45b55c73b076606be 100644 (file)
@@ -40,7 +40,6 @@ gp100_disp = {
        .sor.nr = 4,
        .sor.new = gm200_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gk104_hdmi_ctrl,
        .sor.magic = gm200_sor_magic,
 };
 
index 26f745bf4befcdc41f18fa3c829eaeb17fdc1fe1..4875d4822d42f8bf5d486fc8687206a63c281f8f 100644 (file)
@@ -66,7 +66,6 @@ gp102_disp = {
        .sor.nr = 4,
        .sor.new = gm200_sor_new,
        .sor.hda_eld = gf119_hda_eld,
-       .sor.hdmi = gk104_hdmi_ctrl,
        .sor.magic = gm200_sor_magic,
 };
 
index f9d43768acba7f9ca6d7ff15218e12b9abc0ba1a..387f57bc517b40d88dd8cea8df03df9bec355660 100644 (file)
@@ -39,9 +39,7 @@ gt200_disp = {
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
        .dac = { .nr = 3, .new = nv50_dac_new },
-       .sor.nr = 2,
-       .sor.new = g84_sor_new,
-       .sor.hdmi = g84_hdmi_ctrl,
+       .sor = { .nr = 2, .new = g84_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 6c75a975bf45bff05d2409b43e23be2bebe0110c..4edd371245360782bd9926c9537bbacb491b6f5c 100644 (file)
@@ -43,7 +43,6 @@ gt215_disp = {
        .sor.nr = 4,
        .sor.new = gt215_sor_new,
        .sor.hda_eld = gt215_hda_eld,
-       .sor.hdmi = gt215_hdmi_ctrl,
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 35a825192264825ddd501cd3643c15b748ec245b..528f5621a49632d8c7d83cc9dccb821355ecc051 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __NVKM_DISP_HDMI_H__
 #define __NVKM_DISP_HDMI_H__
-#include "nv50.h"
+#include "ior.h"
 
 struct packed_hdmi_infoframe {
        u32 header;
index f25d8c7fba6778b16c05444ad963baadb2ef6d4e..661410f9b4572fb998a9115f2c8cc60c018c0466 100644 (file)
  */
 #include "hdmi.h"
 
-#include <core/client.h>
-
-#include <nvif/cl5070.h>
-#include <nvif/unpack.h>
-
-int
-g84_hdmi_ctrl(NV50_DISP_MTHD_V1)
+void
+g84_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet,
+             u8 rekey, u8 *avi, u8 avi_size, u8 *vendor, u8 vendor_size)
 {
-       struct nvkm_device *device = disp->base.engine.subdev.device;
-       const u32 hoff = (head * 0x800);
-       union {
-               struct nv50_disp_sor_hdmi_pwr_v0 v0;
-       } *args = data;
+       struct nvkm_device *device = ior->disp->engine.subdev.device;
+       const u32 ctrl = 0x40000000 * enable |
+                        0x1f000000 /* ??? */ |
+                        max_ac_packet << 16 |
+                        rekey;
+       const u32 hoff = head * 0x800;
        struct packed_hdmi_infoframe avi_infoframe;
        struct packed_hdmi_infoframe vendor_infoframe;
-       u32 ctrl;
-       int ret = -ENOSYS;
-
-       nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
-       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-               nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
-                                  "max_ac_packet %d rekey %d\n",
-                          args->v0.version, args->v0.state,
-                          args->v0.max_ac_packet, args->v0.rekey);
-               if (args->v0.max_ac_packet > 0x1f || args->v0.rekey > 0x7f)
-                       return -EINVAL;
-               ctrl  = 0x40000000 * !!args->v0.state;
-               ctrl |= args->v0.max_ac_packet << 16;
-               ctrl |= args->v0.rekey;
-               ctrl |= 0x1f000000; /* ??? */
-       } else
-               return ret;
-
-       if ((args->v0.avi_infoframe_length
-            + args->v0.vendor_infoframe_length) > size)
-               return -ENOSYS;
-       else if ((args->v0.avi_infoframe_length
-                   + args->v0.vendor_infoframe_length) < size)
-               return -E2BIG;
-
-       pack_hdmi_infoframe(&avi_infoframe,
-                           data,
-                           args->v0.avi_infoframe_length);
 
-       pack_hdmi_infoframe(&vendor_infoframe,
-                           data + args->v0.avi_infoframe_length,
-                           args->v0.vendor_infoframe_length);
+       pack_hdmi_infoframe(&avi_infoframe, avi, avi_size);
+       pack_hdmi_infoframe(&vendor_infoframe, vendor, vendor_size);
 
        if (!(ctrl & 0x40000000)) {
                nvkm_mask(device, 0x6165a4 + hoff, 0x40000000, 0x00000000);
                nvkm_mask(device, 0x61653c + hoff, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x616520 + hoff, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x616500 + hoff, 0x00000001, 0x00000000);
-               return 0;
+               return;
        }
 
        /* AVI InfoFrame */
        nvkm_mask(device, 0x616520 + hoff, 0x00000001, 0x00000000);
-       if (args->v0.avi_infoframe_length) {
+       if (avi_size) {
                nvkm_wr32(device, 0x616528 + hoff, avi_infoframe.header);
                nvkm_wr32(device, 0x61652c + hoff, avi_infoframe.subpack0_low);
                nvkm_wr32(device, 0x616530 + hoff, avi_infoframe.subpack0_high);
@@ -99,7 +67,7 @@ g84_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* Vendor InfoFrame */
        nvkm_mask(device, 0x61653c + hoff, 0x00010001, 0x00010000);
-       if (args->v0.vendor_infoframe_length) {
+       if (vendor_size) {
                nvkm_wr32(device, 0x616544 + hoff, vendor_infoframe.header);
                nvkm_wr32(device, 0x616548 + hoff, vendor_infoframe.subpack0_low);
                nvkm_wr32(device, 0x61654c + hoff, vendor_infoframe.subpack0_high);
@@ -120,5 +88,4 @@ g84_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* HDMI_CTRL */
        nvkm_mask(device, 0x6165a4 + hoff, 0x5f1f007f, ctrl);
-       return 0;
 }
index 8dc6a79c814146c0a1d22ae13f803763dfed5f4d..6cac0e72b4cc61b84364dc9b5a81cd542dfb55a2 100644 (file)
  */
 #include "hdmi.h"
 
-#include <core/client.h>
-
-#include <nvif/cl5070.h>
-#include <nvif/unpack.h>
-
-int
-gf119_hdmi_ctrl(NV50_DISP_MTHD_V1)
+void
+gf119_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet,
+               u8 rekey, u8 *avi, u8 avi_size, u8 *vendor, u8 vendor_size)
 {
-       struct nvkm_device *device = disp->base.engine.subdev.device;
-       const u32 hoff = (head * 0x800);
-       union {
-               struct nv50_disp_sor_hdmi_pwr_v0 v0;
-       } *args = data;
+       struct nvkm_device *device = ior->disp->engine.subdev.device;
+       const u32 ctrl = 0x40000000 * enable |
+                        max_ac_packet << 16 |
+                        rekey;
+       const u32 hoff = head * 0x800;
        struct packed_hdmi_infoframe avi_infoframe;
        struct packed_hdmi_infoframe vendor_infoframe;
-       u32 ctrl;
-       int ret = -ENOSYS;
-
-       nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
-       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-               nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
-                                  "max_ac_packet %d rekey %d\n",
-                          args->v0.version, args->v0.state,
-                          args->v0.max_ac_packet, args->v0.rekey);
-               if (args->v0.max_ac_packet > 0x1f || args->v0.rekey > 0x7f)
-                       return -EINVAL;
-               ctrl  = 0x40000000 * !!args->v0.state;
-               ctrl |= args->v0.max_ac_packet << 16;
-               ctrl |= args->v0.rekey;
-       } else
-               return ret;
-
-       if ((args->v0.avi_infoframe_length
-            + args->v0.vendor_infoframe_length) > size)
-               return -ENOSYS;
-       else if ((args->v0.avi_infoframe_length
-                   + args->v0.vendor_infoframe_length) < size)
-               return -E2BIG;
-
-       pack_hdmi_infoframe(&avi_infoframe,
-                           data,
-                           args->v0.avi_infoframe_length);
 
-       pack_hdmi_infoframe(&vendor_infoframe,
-                           data + args->v0.avi_infoframe_length,
-                           args->v0.vendor_infoframe_length);
+       pack_hdmi_infoframe(&avi_infoframe, avi, avi_size);
+       pack_hdmi_infoframe(&vendor_infoframe, vendor, vendor_size);
 
        if (!(ctrl & 0x40000000)) {
                nvkm_mask(device, 0x616798 + hoff, 0x40000000, 0x00000000);
                nvkm_mask(device, 0x616730 + hoff, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x6167a4 + hoff, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x616714 + hoff, 0x00000001, 0x00000000);
-               return 0;
+               return;
        }
 
        /* AVI InfoFrame */
        nvkm_mask(device, 0x616714 + hoff, 0x00000001, 0x00000000);
-       if (args->v0.avi_infoframe_length) {
+       if (avi_size) {
                nvkm_wr32(device, 0x61671c + hoff, avi_infoframe.header);
                nvkm_wr32(device, 0x616720 + hoff, avi_infoframe.subpack0_low);
                nvkm_wr32(device, 0x616724 + hoff, avi_infoframe.subpack0_high);
@@ -91,7 +59,7 @@ gf119_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* GENERIC(?) / Vendor InfoFrame? */
        nvkm_mask(device, 0x616730 + hoff, 0x00010001, 0x00010000);
-       if (args->v0.vendor_infoframe_length) {
+       if (vendor_size) {
                /*
                 * These appear to be the audio infoframe registers,
                 * but no other set of infoframe registers has yet
@@ -111,5 +79,4 @@ gf119_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* HDMI_CTRL */
        nvkm_mask(device, 0x616798 + hoff, 0x401f007f, ctrl);
-       return 0;
 }
index 1be2ecb1ebbc7909d71849fb4fd32f4c1f03a8a2..ed0a6100d76bfdc739ac4257a498333f59a17c38 100644 (file)
  */
 #include "hdmi.h"
 
-#include <core/client.h>
-
-#include <nvif/cl5070.h>
-#include <nvif/unpack.h>
-
-int
-gk104_hdmi_ctrl(NV50_DISP_MTHD_V1)
+void
+gk104_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet,
+               u8 rekey, u8 *avi, u8 avi_size, u8 *vendor, u8 vendor_size)
 {
-       struct nvkm_device *device = disp->base.engine.subdev.device;
-       const u32 hoff = (head * 0x800);
-       const u32 hdmi = (head * 0x400);
-       union {
-               struct nv50_disp_sor_hdmi_pwr_v0 v0;
-       } *args = data;
+       struct nvkm_device *device = ior->disp->engine.subdev.device;
+       const u32 ctrl = 0x40000000 * enable |
+                        max_ac_packet << 16 |
+                        rekey;
+       const u32 hoff = head * 0x800;
+       const u32 hdmi = head * 0x400;
        struct packed_hdmi_infoframe avi_infoframe;
        struct packed_hdmi_infoframe vendor_infoframe;
-       u32 ctrl;
-       int ret = -ENOSYS;
-
-       nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
-       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-               nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
-                                  "max_ac_packet %d rekey %d\n",
-                          args->v0.version, args->v0.state,
-                          args->v0.max_ac_packet, args->v0.rekey);
-               if (args->v0.max_ac_packet > 0x1f || args->v0.rekey > 0x7f)
-                       return -EINVAL;
-               ctrl  = 0x40000000 * !!args->v0.state;
-               ctrl |= args->v0.max_ac_packet << 16;
-               ctrl |= args->v0.rekey;
-       } else
-               return ret;
-
-       if ((args->v0.avi_infoframe_length
-            + args->v0.vendor_infoframe_length) > size)
-               return -ENOSYS;
-       else if ((args->v0.avi_infoframe_length
-                   + args->v0.vendor_infoframe_length) < size)
-               return -E2BIG;
-
-       pack_hdmi_infoframe(&avi_infoframe,
-                           data,
-                           args->v0.avi_infoframe_length);
 
-       pack_hdmi_infoframe(&vendor_infoframe,
-                           data + args->v0.avi_infoframe_length,
-                           args->v0.vendor_infoframe_length);
+       pack_hdmi_infoframe(&avi_infoframe, avi, avi_size);
+       pack_hdmi_infoframe(&vendor_infoframe, vendor, vendor_size);
 
        if (!(ctrl & 0x40000000)) {
                nvkm_mask(device, 0x616798 + hoff, 0x40000000, 0x00000000);
                nvkm_mask(device, 0x690100 + hdmi, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x6900c0 + hdmi, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x690000 + hdmi, 0x00000001, 0x00000000);
-               return 0;
+               return;
        }
 
        /* AVI InfoFrame */
        nvkm_mask(device, 0x690000 + hdmi, 0x00000001, 0x00000000);
-       if (args->v0.avi_infoframe_length) {
+       if (avi_size) {
                nvkm_wr32(device, 0x690008 + hdmi, avi_infoframe.header);
                nvkm_wr32(device, 0x69000c + hdmi, avi_infoframe.subpack0_low);
                nvkm_wr32(device, 0x690010 + hdmi, avi_infoframe.subpack0_high);
@@ -92,7 +60,7 @@ gk104_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* GENERIC(?) / Vendor InfoFrame? */
        nvkm_mask(device, 0x690100 + hdmi, 0x00010001, 0x00000000);
-       if (args->v0.vendor_infoframe_length) {
+       if (vendor_size) {
                nvkm_wr32(device, 0x690108 + hdmi, vendor_infoframe.header);
                nvkm_wr32(device, 0x69010c + hdmi, vendor_infoframe.subpack0_low);
                nvkm_wr32(device, 0x690110 + hdmi, vendor_infoframe.subpack0_high);
@@ -111,5 +79,4 @@ gk104_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* HDMI_CTRL */
        nvkm_mask(device, 0x616798 + hoff, 0x401f007f, ctrl);
-       return 0;
 }
index 16c63fe05539bb9db9c15e3d4adc0fcc5dec4c71..0993d223bb9c0a3997012b35c50356cd23d0e1e1 100644 (file)
  * Authors: Ben Skeggs
  */
 #include "hdmi.h"
-#include "outp.h"
 
-#include <core/client.h>
-
-#include <nvif/cl5070.h>
-#include <nvif/unpack.h>
-
-int
-gt215_hdmi_ctrl(NV50_DISP_MTHD_V1)
+void
+gt215_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet,
+               u8 rekey, u8 *avi, u8 avi_size, u8 *vendor, u8 vendor_size)
 {
-       struct nvkm_device *device = disp->base.engine.subdev.device;
-       const u32 soff = outp->or * 0x800;
-       union {
-               struct nv50_disp_sor_hdmi_pwr_v0 v0;
-       } *args = data;
+       struct nvkm_device *device = ior->disp->engine.subdev.device;
+       const u32 ctrl = 0x40000000 * enable |
+                        0x1f000000 /* ??? */ |
+                        max_ac_packet << 16 |
+                        rekey;
+       const u32 soff = nv50_ior_base(ior);
        struct packed_hdmi_infoframe avi_infoframe;
        struct packed_hdmi_infoframe vendor_infoframe;
-       u32 ctrl;
-       int ret = -ENOSYS;
-
-       nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
-       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
-               nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
-                                  "max_ac_packet %d rekey %d\n",
-                          args->v0.version, args->v0.state,
-                          args->v0.max_ac_packet, args->v0.rekey);
-               if (args->v0.max_ac_packet > 0x1f || args->v0.rekey > 0x7f)
-                       return -EINVAL;
-               ctrl  = 0x40000000 * !!args->v0.state;
-               ctrl |= args->v0.max_ac_packet << 16;
-               ctrl |= args->v0.rekey;
-               ctrl |= 0x1f000000; /* ??? */
-       } else
-               return ret;
-
-       if ((args->v0.avi_infoframe_length
-            + args->v0.vendor_infoframe_length) > size)
-               return -ENOSYS;
-       else if ((args->v0.avi_infoframe_length
-                   + args->v0.vendor_infoframe_length) < size)
-               return -E2BIG;
-
-       pack_hdmi_infoframe(&avi_infoframe,
-                           data,
-                           args->v0.avi_infoframe_length);
 
-       pack_hdmi_infoframe(&vendor_infoframe,
-                           data + args->v0.avi_infoframe_length,
-                           args->v0.vendor_infoframe_length);
+       pack_hdmi_infoframe(&avi_infoframe, avi, avi_size);
+       pack_hdmi_infoframe(&vendor_infoframe, vendor, vendor_size);
 
        if (!(ctrl & 0x40000000)) {
                nvkm_mask(device, 0x61c5a4 + soff, 0x40000000, 0x00000000);
                nvkm_mask(device, 0x61c53c + soff, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x61c520 + soff, 0x00000001, 0x00000000);
                nvkm_mask(device, 0x61c500 + soff, 0x00000001, 0x00000000);
-               return 0;
+               return;
        }
 
        /* AVI InfoFrame */
        nvkm_mask(device, 0x61c520 + soff, 0x00000001, 0x00000000);
-       if (args->v0.avi_infoframe_length) {
+       if (avi_size) {
                nvkm_wr32(device, 0x61c528 + soff, avi_infoframe.header);
                nvkm_wr32(device, 0x61c52c + soff, avi_infoframe.subpack0_low);
                nvkm_wr32(device, 0x61c530 + soff, avi_infoframe.subpack0_high);
@@ -100,7 +67,7 @@ gt215_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* Vendor InfoFrame */
        nvkm_mask(device, 0x61c53c + soff, 0x00010001, 0x00010000);
-       if (args->v0.vendor_infoframe_length) {
+       if (vendor_size) {
                nvkm_wr32(device, 0x61c544 + soff, vendor_infoframe.header);
                nvkm_wr32(device, 0x61c548 + soff, vendor_infoframe.subpack0_low);
                nvkm_wr32(device, 0x61c54c + soff, vendor_infoframe.subpack0_high);
@@ -121,5 +88,4 @@ gt215_hdmi_ctrl(NV50_DISP_MTHD_V1)
 
        /* HDMI_CTRL */
        nvkm_mask(device, 0x61c5a4 + soff, 0x5f1f007f, ctrl);
-       return 0;
 }
index ea80e7fd7d238285d032cc7fed2a7678116ee733..0b5115dac4d6b030cb1187da5d9bc17558635a68 100644 (file)
@@ -43,6 +43,12 @@ struct nvkm_ior_func {
        void (*power)(struct nvkm_ior *, bool normal, bool pu,
                      bool data, bool vsync, bool hsync);
        int (*sense)(struct nvkm_ior *, u32 loadval);
+
+       struct {
+               void (*ctrl)(struct nvkm_ior *, int head, bool enable,
+                            u8 max_ac_packet, u8 rekey, u8 *avi, u8 avi_size,
+                            u8 *vendor, u8 vendor_size);
+       } hdmi;
 };
 
 int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *,
@@ -65,6 +71,11 @@ void nv50_sor_power(struct nvkm_ior *, bool, bool, bool, bool, bool);
 void g94_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
 void gf119_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
 
+void g84_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
+void gt215_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
+void gf119_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
+void gk104_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
+
 #define IOR_MSG(i,l,f,a...) do {                                               \
        struct nvkm_ior *_ior = (i);                                           \
        nvkm_##l(&_ior->disp->engine.subdev, "%s: "f, _ior->name, ##a);        \
index d707d8f4c0f03aa419cb7663befd29ea01cebc62..4f4e4e68de3301a9c7e3fc0f72a28f3829c87dea 100644 (file)
@@ -38,9 +38,7 @@ mcp77_disp = {
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
        .dac = { .nr = 3, .new = nv50_dac_new },
-       .sor.nr = 4,
-       .sor.new = mcp77_sor_new,
-       .sor.hdmi = g84_hdmi_ctrl,
+       .sor = { .nr = 4, .new = mcp77_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 24f46705f6167c623462ec3b6d741a68c14aac08..11ec2960c9ac12679a2fadbdc2fba233c725a028 100644 (file)
@@ -41,7 +41,6 @@ mcp89_disp = {
        .sor.nr = 4,
        .sor.new = mcp89_sor_new,
        .sor.hda_eld = gt215_hda_eld,
-       .sor.hdmi = gt215_hdmi_ctrl,
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 263c3a7f9d8880486d6d277c6f92e03656c5028c..aa7b0739d874b8778c1f912c20d3bd53e085eaba 100644 (file)
@@ -34,11 +34,6 @@ void nv50_disp_super_1(struct nv50_disp *);
 int gt215_hda_eld(NV50_DISP_MTHD_V1);
 int gf119_hda_eld(NV50_DISP_MTHD_V1);
 
-int g84_hdmi_ctrl(NV50_DISP_MTHD_V1);
-int gt215_hdmi_ctrl(NV50_DISP_MTHD_V1);
-int gf119_hdmi_ctrl(NV50_DISP_MTHD_V1);
-int gk104_hdmi_ctrl(NV50_DISP_MTHD_V1);
-
 int nv50_disp_new_(const struct nv50_disp_func *, struct nvkm_device *,
                   int index, int heads, struct nvkm_disp **);
 int gf119_disp_new_(const struct nv50_disp_func *, struct nvkm_device *,
@@ -84,7 +79,6 @@ struct nv50_disp_func {
                int nr;
                int (*new)(struct nvkm_disp *, int id);
                int (*hda_eld)(NV50_DISP_MTHD_V1);
-               int (*hdmi)(NV50_DISP_MTHD_V1);
                void (*magic)(struct nvkm_output *);
        } sor;
 
index 7ebea3e14e18208a4c6b7c17d4ec00d30e0c5e25..a81928de6dcdb39cccb8463f25f95431facb9a8e 100644 (file)
@@ -116,10 +116,46 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
                if (!func->sor.hda_eld)
                        return -ENODEV;
                return func->sor.hda_eld(object, disp, data, size, hidx, outp);
-       case NV50_DISP_MTHD_V1_SOR_HDMI_PWR:
-               if (!func->sor.hdmi)
+       case NV50_DISP_MTHD_V1_SOR_HDMI_PWR: {
+               union {
+                       struct nv50_disp_sor_hdmi_pwr_v0 v0;
+               } *args = data;
+               u8 *vendor, vendor_size;
+               u8 *avi, avi_size;
+               int ret = -ENOSYS;
+
+               nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
+               if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
+                       nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
+                                          "max_ac_packet %d rekey %d\n",
+                                  args->v0.version, args->v0.state,
+                                  args->v0.max_ac_packet, args->v0.rekey);
+                       if (args->v0.max_ac_packet > 0x1f || args->v0.rekey > 0x7f)
+                               return -EINVAL;
+                       if ((args->v0.avi_infoframe_length
+                            + args->v0.vendor_infoframe_length) > size)
+                               return -EINVAL;
+                       else
+                       if ((args->v0.avi_infoframe_length
+                            + args->v0.vendor_infoframe_length) < size)
+                               return -E2BIG;
+                       avi = data;
+                       avi_size = args->v0.avi_infoframe_length;
+                       vendor = avi + avi_size;
+                       vendor_size = args->v0.vendor_infoframe_length;
+               } else
+                       return ret;
+
+               if (!outp->ior->func->hdmi.ctrl)
                        return -ENODEV;
-               return func->sor.hdmi(object, disp, data, size, hidx, outp);
+
+               outp->ior->func->hdmi.ctrl(outp->ior, hidx, args->v0.state,
+                                          args->v0.max_ac_packet,
+                                          args->v0.rekey, avi, avi_size,
+                                          vendor, vendor_size);
+               return 0;
+       }
+               break;
        case NV50_DISP_MTHD_V1_SOR_LVDS_SCRIPT: {
                union {
                        struct nv50_disp_sor_lvds_script_v0 v0;
index bb0f503ee989f38b87a1aa371c16e7a30a166320..8913b5f58103ff4d7e4ba5e730aa7c8d30fa1452 100644 (file)
@@ -25,6 +25,9 @@ static const struct nvkm_ior_func
 g84_sor = {
        .state = nv50_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = g84_hdmi_ctrl,
+       },
 };
 
 int
index dcab72a529644d86fe7672650cd229fa1e16330d..c3ce42e7a12e35d2b520f20f65eef8dd6a71e3db 100644 (file)
@@ -157,6 +157,9 @@ static const struct nvkm_ior_func
 gf119_sor = {
        .state = gf119_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = gf119_hdmi_ctrl,
+       },
 };
 
 int
index ac7a5944487a1d4c8d6df87cad24a585545b86a4..9f71f9438c6ab853219c644e7ad1e7ad798907b4 100644 (file)
@@ -25,6 +25,9 @@ static const struct nvkm_ior_func
 gk104_sor = {
        .state = gf119_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = gk104_hdmi_ctrl,
+       },
 };
 
 int
index 8bca4dca1e11055004357cdc89d9837b648b0242..acffeff59a70c0314b9c8efeaecfe9c8a3eee7ad 100644 (file)
@@ -57,6 +57,9 @@ static const struct nvkm_ior_func
 gm107_sor = {
        .state = gf119_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = gk104_hdmi_ctrl,
+       },
 };
 
 int
index 0a4b9b967904290fc1a27b4dc052dab03d936599..c8773d0580730918e8c5dc85576c0e82019a6026 100644 (file)
@@ -134,6 +134,9 @@ static const struct nvkm_ior_func
 gm200_sor = {
        .state = gf119_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = gk104_hdmi_ctrl,
+       },
 };
 
 int
index bec04ad40494309d94dcce541b59cf8e1162159d..7036eeeace570f89de4abdf8b813f592822afa83 100644 (file)
@@ -25,6 +25,9 @@ static const struct nvkm_ior_func
 gt215_sor = {
        .state = g94_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = gt215_hdmi_ctrl,
+       },
 };
 
 int
index fc14e48fe84b0f91696160f5ed4476d1596e2722..a074a4733ca0409d172810b0424a0ed5cf149530 100644 (file)
@@ -25,6 +25,9 @@ static const struct nvkm_ior_func
 mcp77_sor = {
        .state = g94_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = g84_hdmi_ctrl,
+       },
 };
 
 int
index 37c1dacb7d67cd36f0eb9821aafe1bb36f1e39d9..56cf11ff0659226492a0d62684c4e90bf463dba2 100644 (file)
@@ -25,6 +25,9 @@ static const struct nvkm_ior_func
 mcp89_sor = {
        .state = g94_sor_state,
        .power = nv50_sor_power,
+       .hdmi = {
+               .ctrl = gt215_hdmi_ctrl,
+       },
 };
 
 int