remove output names
authorDave Airlie <airlied@redhat.com>
Tue, 18 Dec 2007 06:41:20 +0000 (17:41 +1100)
committerDave Airlie <airlied@redhat.com>
Tue, 18 Dec 2007 06:41:20 +0000 (17:41 +1100)
12 files changed:
libdrm/xf86drmMode.c
libdrm/xf86drmMode.h
linux-core/drm_bo.c
linux-core/drm_crtc.c
linux-core/drm_crtc.h
linux-core/drm_edid.c
linux-core/intel_crt.c
linux-core/intel_lvds.c
linux-core/intel_sdvo.c
shared-core/drm.h
shared-core/i915_init.c
tests/mode/modetest.c

index 726c55a..0edb1d7 100644 (file)
@@ -328,6 +328,8 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id)
        drmModeOutputPtr r = NULL;
 
        out.output = output_id;
+       out.output_type_id = 0;
+       out.output_type  = 0;
        out.count_crtcs  = 0;
        out.crtcs        = 0;
        out.count_clones = 0;
@@ -372,8 +374,8 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id)
        r->props        = drmAllocCpy(U642VOID(out.props_ptr), out.count_props, sizeof(uint32_t));
        r->prop_values  = drmAllocCpy(U642VOID(out.prop_values_ptr), out.count_props, sizeof(uint64_t));
        r->modes        = drmAllocCpy(U642VOID(out.modes_ptr), out.count_modes, sizeof(struct drm_mode_modeinfo));
-       strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN);
-       r->name[DRM_OUTPUT_NAME_LEN-1] = 0;
+       r->output_type  = out.output_type;
+       r->output_type_id = out.output_type_id;
 
 err_allocs:
        drmFree(U642VOID(out.prop_values_ptr));
index 05b61bc..e2dda8a 100644 (file)
@@ -125,7 +125,8 @@ typedef struct _drmModeOutput {
        unsigned int output_id;
 
        unsigned int crtc; /**< Crtc currently connected to */
-       unsigned char name[DRM_OUTPUT_NAME_LEN];
+       unsigned int output_type;
+       unsigned int output_type_id;
        drmModeConnection connection;
        uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
        drmModeSubPixel subpixel;
index 7a123da..c89d660 100644 (file)
@@ -1650,7 +1650,7 @@ int drm_buffer_object_create(struct drm_device *dev,
        size += buffer_start & ~PAGE_MASK;
        num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
        if (num_pages == 0) {
-               DRM_ERROR("Illegal buffer object size.\n");
+               DRM_ERROR("Illegal buffer object size %d.\n", size);
                return -EINVAL;
        }
 
index e1b37c0..9a840ea 100644 (file)
@@ -58,7 +58,22 @@ static struct drm_prop_enum_list drm_conn_enum_list[] =
   { ConnectorHDMIA, "HDMI Type A" },
   { ConnectorHDMIB, "HDMI Type B" },
 };
+static struct drm_prop_enum_list drm_output_enum_list[] =
+{ { DRM_MODE_OUTPUT_NONE, "None" },
+  { DRM_MODE_OUTPUT_DAC, "DAC" },
+  { DRM_MODE_OUTPUT_TMDS, "TMDS" },
+  { DRM_MODE_OUTPUT_LVDS, "LVDS" },
+  { DRM_MODE_OUTPUT_TVDAC, "TV" },
+};
 
+char *drm_get_output_name(struct drm_output *output)
+{
+       static char buf[32];
+
+       snprintf(buf, 32, "%s-%d", drm_output_enum_list[output->output_type].name,
+                output->output_type_id);
+       return buf;
+}
 
 /**
  * drm_idr_get - allocate a new identifier
@@ -322,7 +337,7 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int
        output->status = (*output->funcs->detect)(output);
        
        if (output->status == output_status_disconnected) {
-               DRM_DEBUG("%s is disconnected\n", output->name);
+               DRM_DEBUG("%s is disconnected\n", drm_get_output_name(output));
                /* TODO set EDID to NULL */
                return;
        }
@@ -347,7 +362,7 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int
        if (list_empty(&output->modes)) {
                struct drm_display_mode *stdmode;
                
-               DRM_DEBUG("No valid modes on %s\n", output->name);
+               DRM_DEBUG("No valid modes on %s\n", drm_get_output_name(output));
                
                /* Should we do this here ???
                 * When no valid EDID modes are available we end up
@@ -360,12 +375,12 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int
                                     &output->modes);
                
                DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n",
-                         output->name);
+                         drm_get_output_name(output));
        }
        
        drm_mode_sort(&output->modes);
        
-       DRM_DEBUG("Probed modes for %s\n", output->name);
+       DRM_DEBUG("Probed modes for %s\n", drm_get_output_name(output));
        list_for_each_entry_safe(mode, t, &output->modes, head) {
                mode->vrefresh = drm_mode_vrefresh(mode);
                
@@ -472,7 +487,7 @@ bool drm_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
                if (output->crtc != crtc)
                        continue;
                
-               DRM_INFO("%s: set mode %s %x\n", output->name, mode->name, mode->mode_id);
+               DRM_INFO("%s: set mode %s %x\n", drm_get_output_name(output), mode->name, mode->mode_id);
 
                output->funcs->mode_set(output, mode, adjusted_mode);
        }
@@ -591,7 +606,7 @@ EXPORT_SYMBOL(drm_mode_remove);
  */
 struct drm_output *drm_output_create(struct drm_device *dev,
                                     const struct drm_output_funcs *funcs,
-                                    const char *name)
+                                    int output_type)
 {
        struct drm_output *output = NULL;
 
@@ -602,9 +617,8 @@ struct drm_output *drm_output_create(struct drm_device *dev,
        output->dev = dev;
        output->funcs = funcs;
        output->id = drm_idr_get(dev, output);
-       if (name)
-               strncpy(output->name, name, DRM_OUTPUT_LEN);
-       output->name[DRM_OUTPUT_LEN - 1] = 0;
+       output->output_type = output_type;
+       output->output_type_id = 1; /* TODO */
        output->subpixel_order = SubPixelUnknown;
        INIT_LIST_HEAD(&output->user_modes);
        INIT_LIST_HEAD(&output->probed_modes);
@@ -663,35 +677,6 @@ void drm_output_destroy(struct drm_output *output)
 }
 EXPORT_SYMBOL(drm_output_destroy);
 
-/**
- * drm_output_rename - rename an output
- * @output: output to rename
- * @name: new user visible name
- *
- * LOCKING:
- * None.
- *
- * Simply stuff a new name into @output's name field, based on @name.
- *
- * RETURNS:
- * True if the name was changed, false otherwise.
- */
-bool drm_output_rename(struct drm_output *output, const char *name)
-{
-       if (!name)
-               return false;
-
-       strncpy(output->name, name, DRM_OUTPUT_LEN);
-       output->name[DRM_OUTPUT_LEN - 1] = 0;
-
-       DRM_DEBUG("Changed name to %s\n", output->name);
-//     drm_output_set_monitor(output);
-//     if (drm_output_ignored(output))
-//             return FALSE;
-
-       return TRUE;
-}
-EXPORT_SYMBOL(drm_output_rename);
 
 /**
  * drm_mode_create - create a new display mode
@@ -912,7 +897,7 @@ static void drm_pick_crtcs (struct drm_device *dev)
                                        list_for_each_entry(modes_equal, &output_equal->modes, head) {
                                                if (drm_mode_equal (modes, modes_equal)) {
                                                        if ((output->possible_clones & output_equal->possible_clones) && (output_equal->crtc == crtc)) {
-                                                               printk("Cloning %s (0x%lx) to %s (0x%lx)\n",output->name,output->possible_clones,output_equal->name,output_equal->possible_clones);
+                                                               printk("Cloning %s (0x%lx) to %s (0x%lx)\n",drm_get_output_name(output),output->possible_clones,drm_get_output_name(output_equal),output_equal->possible_clones);
                                                                assigned = 0;
                                                                goto clone;
                                                        }
@@ -1408,9 +1393,8 @@ int drm_mode_getoutput(struct drm_device *dev,
                drm_crtc_probe_single_output_modes(output, dev->mode_config.max_width, dev->mode_config.max_height);
        }
 
-       strncpy(out_resp->name, output->name, DRM_OUTPUT_NAME_LEN);
-       out_resp->name[DRM_OUTPUT_NAME_LEN-1] = 0;
-
+       out_resp->output_type = output->output_type;
+       out_resp->output_type_id = output->output_type_id;
        out_resp->mm_width = output->mm_width;
        out_resp->mm_height = output->mm_height;
        out_resp->subpixel = output->subpixel_order;
index 6b6e1db..dbb4186 100644 (file)
@@ -433,7 +433,6 @@ struct drm_output_funcs {
  * @subpixel_order: for this output
  * @mm_width: displayable width of output in mm
  * @mm_height: displayable height of output in mm
- * @name: name of output (should be one of a few standard names)
  * @funcs: output control functions
  * @driver_private: private driver data
  *
@@ -447,6 +446,9 @@ struct drm_output {
        struct list_head head;
        struct drm_crtc *crtc;
        int id; /* idr assigned */
+
+       int output_type;
+       int output_type_id;
        unsigned long possible_crtcs;
        unsigned long possible_clones;
        bool interlace_allowed;
@@ -467,8 +469,7 @@ struct drm_output {
        enum subpixel_order subpixel_order;
        int mm_width, mm_height;
        struct drm_display_info *monitor_info; /* if any */
-       char name[DRM_OUTPUT_LEN];
-       const struct drm_output_funcs *funcs;
+       const struct drm_output_funcs *funcs;
        void *driver_private;
 
        struct list_head user_modes;
@@ -526,9 +527,10 @@ struct drm_mode_config {
 
 struct drm_output *drm_output_create(struct drm_device *dev,
                                     const struct drm_output_funcs *funcs,
-                                    const char *name);
+                                    int type);
+
+extern char *drm_get_output_name(struct drm_output *output);
 extern void drm_output_destroy(struct drm_output *output);
-extern bool drm_output_rename(struct drm_output *output, const char *name);
 extern void drm_fb_release(struct file *filp);
 
 extern struct edid *drm_get_edid(struct drm_output *output,
index 7068cef..41aa8f5 100644 (file)
@@ -443,12 +443,12 @@ struct edid *drm_get_edid(struct drm_output *output,
        edid = (struct edid *)drm_ddc_read(adapter);
        if (!edid) {
                dev_warn(&output->dev->pdev->dev, "%s: no EDID data\n",
-                        output->name);
+                        drm_get_output_name(output));
                return NULL;
        }
        if (!edid_valid(edid)) {
                dev_warn(&output->dev->pdev->dev, "%s: EDID invalid.\n",
-                        output->name);
+                        drm_get_output_name(output));
                kfree(edid);
                return NULL;
        }
@@ -474,7 +474,7 @@ int drm_add_edid_modes(struct drm_output *output, struct edid *edid)
        }
        if (!edid_valid(edid)) {
                dev_warn(&output->dev->pdev->dev, "%s: EDID invalid.\n",
-                        output->name);
+                        drm_get_output_name(output));
                return 0;
        }
        num_modes += add_established_modes(output, edid);
index 722a62c..74e3dcd 100644 (file)
@@ -240,7 +240,8 @@ void intel_crt_init(struct drm_device *dev)
        struct drm_output *output;
        struct intel_output *intel_output;
 
-       output = drm_output_create(dev, &intel_crt_output_funcs, "VGA");
+       output = drm_output_create(dev, &intel_crt_output_funcs,
+                                  DRM_MODE_OUTPUT_DAC);
 
        intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL);
        if (!intel_output) {
index 94232b9..80f77af 100644 (file)
@@ -372,7 +372,8 @@ void intel_lvds_init(struct drm_device *dev)
        u32 lvds;
        int pipe;
 
-       output = drm_output_create(dev, &intel_lvds_output_funcs, "LVDS");
+       output = drm_output_create(dev, &intel_lvds_output_funcs,
+                                  DRM_MODE_OUTPUT_LVDS);
        if (!output)
                return;
 
index 0da57fa..7f55829 100644 (file)
@@ -953,12 +953,10 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
        int connector_type;
        u8 ch[0x40];
        int i;
-       char name[DRM_OUTPUT_LEN];
-       char *name_prefix;
-       char *name_suffix;
-       
+       int output_type, output_id;
 
-       output = drm_output_create(dev, &intel_sdvo_output_funcs, NULL);
+       output = drm_output_create(dev, &intel_sdvo_output_funcs,
+                                  DRM_MODE_OUTPUT_NONE);
        if (!output)
                return;
 
@@ -988,10 +986,10 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
        sdvo_priv->i2c_bus = i2cbus;
 
        if (output_device == SDVOB) {
-               name_suffix = "-1";
+               output_id = 1;
                sdvo_priv->i2c_bus->slave_addr = 0x38;
        } else {
-               name_suffix = "-2";
+               output_id = 2;
                sdvo_priv->i2c_bus->slave_addr = 0x39;
        }
 
@@ -1019,28 +1017,28 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
        {
                sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0;
                output->subpixel_order = SubPixelHorizontalRGB;
-               name_prefix="RGB";
+               output_type = DRM_MODE_OUTPUT_DAC;
                connector_type = ConnectorVGA;
        }
        else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1)
        {
                sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1;
                output->subpixel_order = SubPixelHorizontalRGB;
-               name_prefix="RGB";
+               output_type = DRM_MODE_OUTPUT_DAC;
                connector_type = ConnectorVGA;
        }
        else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0)
        {
                sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0;
                output->subpixel_order = SubPixelHorizontalRGB;
-               name_prefix="TMDS";
+               output_type = DRM_MODE_OUTPUT_TMDS;
                connector_type = ConnectorDVID;
        }
        else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1)
        {
                sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS1;
                output->subpixel_order = SubPixelHorizontalRGB;
-               name_prefix="TMDS";
+               output_type = DRM_MODE_OUTPUT_TMDS;
                connector_type = ConnectorDVID;
        }
        else
@@ -1054,14 +1052,9 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
                drm_output_destroy(output);
                return;
        }
-       strcpy (name, name_prefix);
-       strcat (name, name_suffix);
-       if (!drm_output_rename(output, name))
-       {
-               drm_output_destroy(output);
-               return;
-       }
-               
+       
+       output->output_type = output_type;
+       output->output_type_id = output_id;
 
        /* Set the input timing to the screen. Assume always input 0. */
        intel_sdvo_set_target_input(output, true, false);
index 9a8dc1d..f8d4404 100644 (file)
@@ -950,6 +950,12 @@ struct drm_mode_crtc {
        struct drm_mode_modeinfo mode;
 };
 
+#define DRM_MODE_OUTPUT_NONE 0
+#define DRM_MODE_OUTPUT_DAC  1
+#define DRM_MODE_OUTPUT_TMDS 2
+#define DRM_MODE_OUTPUT_LVDS 3
+#define DRM_MODE_OUTPUT_TVDAC 4
+
 struct drm_mode_get_output {
 
        uint64_t modes_ptr;
@@ -960,7 +966,8 @@ struct drm_mode_get_output {
        int count_props;
        unsigned int output; /**< Id */
        unsigned int crtc; /**< Id of crtc */
-       unsigned char name[DRM_OUTPUT_NAME_LEN];
+       unsigned int output_type;
+       unsigned int output_type_id;
 
        unsigned int connection;
        unsigned int mm_width, mm_height; /**< HxW in millimeters */
index 3b43c72..e44cb93 100644 (file)
@@ -188,8 +188,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        ret = drm_buffer_object_create(dev, size, drm_bo_type_kernel,
                                       DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
                                       DRM_BO_FLAG_MEM_VRAM |
-                                      DRM_BO_FLAG_NO_EVICT |
-                                      DRM_BO_HINT_DONT_FENCE, 0, 0x1, 0,
+                                      DRM_BO_FLAG_NO_EVICT,
+                                      DRM_BO_HINT_DONT_FENCE, 0x1, 0,
                                       &dev_priv->ring_buffer);
        if (ret < 0) {
                DRM_ERROR("Unable to allocate or pin ring buffer\n");
index f1fe64d..bd8372d 100644 (file)
@@ -54,7 +54,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id)
        drmModePropertyPtr props;
        unsigned char *name = NULL;
 
-       printf("Output: %s\n", output->name);
+       printf("Output: %d-%d\n", output->output_type, output->output_type_id);
        printf("\tid           : %i\n", id);
        printf("\tcrtc id      : %i\n", output->crtc);
        printf("\tconn         : %s\n", getConnectionText(output->connection));