aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_tv.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-09-04 19:52:34 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 05:13:37 -0400
commit763a4a019105dccdcd44883f1712571ae8ea8f1f (patch)
treeb1d5935ab438cc9b09696a3d8714c74086579a08 /drivers/gpu/drm/i915/intel_tv.c
parent974b93315b2213b74a42a87e8a9d4fc8c0dbe90c (diff)
drm/i915/tv: Mark the format names as constant and so avoid the memleak
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_tv.c')
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index b7f4dca186a9..4a6534239fa3 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -48,7 +48,7 @@ struct intel_tv {
48 struct intel_encoder base; 48 struct intel_encoder base;
49 49
50 int type; 50 int type;
51 char *tv_format; 51 const char *tv_format;
52 int margin[4]; 52 int margin[4];
53 u32 save_TV_H_CTL_1; 53 u32 save_TV_H_CTL_1;
54 u32 save_TV_H_CTL_2; 54 u32 save_TV_H_CTL_2;
@@ -350,7 +350,7 @@ static const struct video_levels component_levels = {
350 350
351 351
352struct tv_mode { 352struct tv_mode {
353 char *name; 353 const char *name;
354 int clock; 354 int clock;
355 int refresh; /* in millihertz (for precision) */ 355 int refresh; /* in millihertz (for precision) */
356 u32 oversample; 356 u32 oversample;
@@ -922,7 +922,7 @@ intel_tv_dpms(struct drm_encoder *encoder, int mode)
922} 922}
923 923
924static const struct tv_mode * 924static const struct tv_mode *
925intel_tv_mode_lookup (char *tv_format) 925intel_tv_mode_lookup(const char *tv_format)
926{ 926{
927 int i; 927 int i;
928 928
@@ -936,13 +936,14 @@ intel_tv_mode_lookup (char *tv_format)
936} 936}
937 937
938static const struct tv_mode * 938static const struct tv_mode *
939intel_tv_mode_find (struct intel_tv *intel_tv) 939intel_tv_mode_find(struct intel_tv *intel_tv)
940{ 940{
941 return intel_tv_mode_lookup(intel_tv->tv_format); 941 return intel_tv_mode_lookup(intel_tv->tv_format);
942} 942}
943 943
944static enum drm_mode_status 944static enum drm_mode_status
945intel_tv_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) 945intel_tv_mode_valid(struct drm_connector *connector,
946 struct drm_display_mode *mode)
946{ 947{
947 struct drm_encoder *encoder = intel_attached_encoder(connector); 948 struct drm_encoder *encoder = intel_attached_encoder(connector);
948 struct intel_tv *intel_tv = enc_to_intel_tv(encoder); 949 struct intel_tv *intel_tv = enc_to_intel_tv(encoder);
@@ -952,6 +953,7 @@ intel_tv_mode_valid(struct drm_connector *connector, struct drm_display_mode *mo
952 if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode) * 1000) 953 if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode) * 1000)
953 < 1000) 954 < 1000)
954 return MODE_OK; 955 return MODE_OK;
956
955 return MODE_CLOCK_RANGE; 957 return MODE_CLOCK_RANGE;
956} 958}
957 959
@@ -1369,11 +1371,10 @@ intel_tv_detect(struct drm_connector *connector)
1369 return connector_status_connected; 1371 return connector_status_connected;
1370} 1372}
1371 1373
1372static struct input_res { 1374static const struct input_res {
1373 char *name; 1375 const char *name;
1374 int w, h; 1376 int w, h;
1375} input_res_table[] = 1377} input_res_table[] = {
1376{
1377 {"640x480", 640, 480}, 1378 {"640x480", 640, 480},
1378 {"800x600", 800, 600}, 1379 {"800x600", 800, 600},
1379 {"1024x768", 1024, 768}, 1380 {"1024x768", 1024, 768},
@@ -1424,7 +1425,7 @@ intel_tv_get_modes(struct drm_connector *connector)
1424 1425
1425 for (j = 0; j < ARRAY_SIZE(input_res_table); 1426 for (j = 0; j < ARRAY_SIZE(input_res_table);
1426 j++) { 1427 j++) {
1427 struct input_res *input = &input_res_table[j]; 1428 const struct input_res *input = &input_res_table[j];
1428 unsigned int hactive_s = input->w; 1429 unsigned int hactive_s = input->w;
1429 unsigned int vactive_s = input->h; 1430 unsigned int vactive_s = input->h;
1430 1431
@@ -1601,7 +1602,7 @@ intel_tv_init(struct drm_device *dev)
1601 struct intel_encoder *intel_encoder; 1602 struct intel_encoder *intel_encoder;
1602 struct intel_connector *intel_connector; 1603 struct intel_connector *intel_connector;
1603 u32 tv_dac_on, tv_dac_off, save_tv_dac; 1604 u32 tv_dac_on, tv_dac_off, save_tv_dac;
1604 char **tv_format_names; 1605 char *tv_format_names[ARRAY_SIZE(tv_modes)];
1605 int i, initial_mode = 0; 1606 int i, initial_mode = 0;
1606 1607
1607 if ((I915_READ(TV_CTL) & TV_FUSE_STATE_MASK) == TV_FUSE_STATE_DISABLED) 1608 if ((I915_READ(TV_CTL) & TV_FUSE_STATE_MASK) == TV_FUSE_STATE_DISABLED)
@@ -1672,7 +1673,7 @@ intel_tv_init(struct drm_device *dev)
1672 intel_tv->margin[TV_MARGIN_RIGHT] = 46; 1673 intel_tv->margin[TV_MARGIN_RIGHT] = 46;
1673 intel_tv->margin[TV_MARGIN_BOTTOM] = 37; 1674 intel_tv->margin[TV_MARGIN_BOTTOM] = 37;
1674 1675
1675 intel_tv->tv_format = kstrdup(tv_modes[initial_mode].name, GFP_KERNEL); 1676 intel_tv->tv_format = tv_modes[initial_mode].name;
1676 1677
1677 drm_encoder_helper_add(&intel_encoder->enc, &intel_tv_helper_funcs); 1678 drm_encoder_helper_add(&intel_encoder->enc, &intel_tv_helper_funcs);
1678 drm_connector_helper_add(connector, &intel_tv_connector_helper_funcs); 1679 drm_connector_helper_add(connector, &intel_tv_connector_helper_funcs);
@@ -1680,13 +1681,11 @@ intel_tv_init(struct drm_device *dev)
1680 connector->doublescan_allowed = false; 1681 connector->doublescan_allowed = false;
1681 1682
1682 /* Create TV properties then attach current values */ 1683 /* Create TV properties then attach current values */
1683 tv_format_names = kmalloc(sizeof(char *) * ARRAY_SIZE(tv_modes),
1684 GFP_KERNEL);
1685 if (!tv_format_names)
1686 goto out;
1687 for (i = 0; i < ARRAY_SIZE(tv_modes); i++) 1684 for (i = 0; i < ARRAY_SIZE(tv_modes); i++)
1688 tv_format_names[i] = tv_modes[i].name; 1685 tv_format_names[i] = (char *)tv_modes[i].name;
1689 drm_mode_create_tv_properties(dev, ARRAY_SIZE(tv_modes), tv_format_names); 1686 drm_mode_create_tv_properties(dev,
1687 ARRAY_SIZE(tv_modes),
1688 tv_format_names);
1690 1689
1691 drm_connector_attach_property(connector, dev->mode_config.tv_mode_property, 1690 drm_connector_attach_property(connector, dev->mode_config.tv_mode_property,
1692 initial_mode); 1691 initial_mode);
@@ -1702,6 +1701,5 @@ intel_tv_init(struct drm_device *dev)
1702 drm_connector_attach_property(connector, 1701 drm_connector_attach_property(connector,
1703 dev->mode_config.tv_bottom_margin_property, 1702 dev->mode_config.tv_bottom_margin_property,
1704 intel_tv->margin[TV_MARGIN_BOTTOM]); 1703 intel_tv->margin[TV_MARGIN_BOTTOM]);
1705out:
1706 drm_sysfs_connector_add(connector); 1704 drm_sysfs_connector_add(connector);
1707} 1705}