~ubuntu-branches/ubuntu/trusty/grub2/trusty

« back to all changes in this revision

Viewing changes to grub-core/commands/videoinfo.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-16 15:18:04 UTC
  • mfrom: (17.6.38 experimental)
  • Revision ID: package-import@ubuntu.com-20140116151804-3foouk7fpqcq3sxx
Tags: 2.02~beta2-2
* Convert patch handling to git-dpm.
* Add bi-endian support to ELF parser (Tomohiro B Berry).
* Adjust restore_mkdevicemap.patch to mark get_kfreebsd_version as static,
  to appease "gcc -Werror=missing-prototypes".
* Cherry-pick from upstream:
  - Change grub-macbless' manual page section to 8.
* Install grub-glue-efi, grub-macbless, grub-render-label, and
  grub-syslinux2cfg.
* grub-shell: Pass -no-pad to xorriso when building floppy images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
GRUB_MOD_LICENSE ("GPLv3+");
29
29
 
30
 
static unsigned height, width, depth; 
31
 
static struct grub_video_mode_info *current_mode;
 
30
struct hook_ctx
 
31
{
 
32
  unsigned height, width, depth; 
 
33
  struct grub_video_mode_info *current_mode;
 
34
};
32
35
 
33
36
static int
34
 
hook (const struct grub_video_mode_info *info)
 
37
hook (const struct grub_video_mode_info *info, void *hook_arg)
35
38
{
36
 
  if (height && width && (info->width != width || info->height != height))
 
39
  struct hook_ctx *ctx = hook_arg;
 
40
 
 
41
  if (ctx->height && ctx->width && (info->width != ctx->width || info->height != ctx->height))
37
42
    return 0;
38
43
 
39
 
  if (depth && info->bpp != depth)
 
44
  if (ctx->depth && info->bpp != ctx->depth)
40
45
    return 0;
41
46
 
42
47
  if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
43
48
    grub_printf ("        ");
44
49
  else
45
50
    {
46
 
      if (current_mode && info->mode_number == current_mode->mode_number)
 
51
      if (ctx->current_mode && info->mode_number == ctx->current_mode->mode_number)
47
52
        grub_printf ("*");
48
53
      else
49
54
        grub_printf (" ");
68
73
                  info->blue_field_pos,
69
74
                  info->reserved_field_pos);
70
75
  if (info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
71
 
    /* TRANSLATORS: In "packed pixel" mode you write the index of the color
72
 
       in the palette. Synonyms include "paletted color".  */
73
 
    grub_xputs (_("Packed pixel "));
 
76
    /* TRANSLATORS: In "paletted color" mode you write the index of the color
 
77
       in the palette. Synonyms include "packed pixel".  */
 
78
    grub_xputs (_("Paletted "));
74
79
  if (info->mode_type & GRUB_VIDEO_MODE_TYPE_YUV)
75
80
    grub_xputs (_("YUV "));
76
81
  if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PLANAR)
126
131
{
127
132
  grub_video_adapter_t adapter;
128
133
  grub_video_driver_id_t id;
 
134
  struct hook_ctx ctx;
129
135
 
130
 
  height = width = depth = 0;
 
136
  ctx.height = ctx.width = ctx.depth = 0;
131
137
  if (argc)
132
138
    {
133
139
      char *ptr;
134
140
      ptr = args[0];
135
 
      width = grub_strtoul (ptr, &ptr, 0);
 
141
      ctx.width = grub_strtoul (ptr, &ptr, 0);
136
142
      if (grub_errno)
137
143
        return grub_errno;
138
144
      if (*ptr != 'x')
140
146
                           N_("invalid video mode specification `%s'"),
141
147
                           args[0]);
142
148
      ptr++;
143
 
      height = grub_strtoul (ptr, &ptr, 0);
 
149
      ctx.height = grub_strtoul (ptr, &ptr, 0);
144
150
      if (grub_errno)
145
151
        return grub_errno;
146
152
      if (*ptr == 'x')
147
153
        {
148
154
          ptr++;
149
 
          depth = grub_strtoul (ptr, &ptr, 0);
 
155
          ctx.depth = grub_strtoul (ptr, &ptr, 0);
150
156
          if (grub_errno)
151
157
            return grub_errno;
152
158
        }
175
181
        continue;
176
182
      }
177
183
 
178
 
    current_mode = NULL;
 
184
    ctx.current_mode = NULL;
179
185
 
180
186
    if (adapter->id == id)
181
187
      {
182
188
        if (grub_video_get_info (&info) == GRUB_ERR_NONE)
183
 
          current_mode = &info;
 
189
          ctx.current_mode = &info;
184
190
        else
185
191
          /* Don't worry about errors.  */
186
192
          grub_errno = GRUB_ERR_NONE;
198
204
    if (adapter->print_adapter_specific_info)
199
205
      adapter->print_adapter_specific_info ();
200
206
 
201
 
    adapter->iterate (hook);
 
207
    adapter->iterate (hook, &ctx);
202
208
 
203
209
    if (adapter->get_edid && adapter->get_edid (&edid_info) == GRUB_ERR_NONE)
204
210
      print_edid (&edid_info);
205
211
    else
206
212
      grub_errno = GRUB_ERR_NONE;
207
213
 
208
 
    current_mode = NULL;
 
214
    ctx.current_mode = NULL;
209
215
 
210
216
    if (adapter->id != id)
211
217
      {