linux/drivers/staging/easycap/easycap_settings.c
<<
>>
Prefs
   1/******************************************************************************
   2*                                                                             *
   3*  easycap_settings.c                                                         *
   4*                                                                             *
   5******************************************************************************/
   6/*
   7 *
   8 *  Copyright (C) 2010 R.M. Thomas  <rmthomas@sciolus.org>
   9 *
  10 *
  11 *  This is free software; you can redistribute it and/or modify
  12 *  it under the terms of the GNU General Public License as published by
  13 *  the Free Software Foundation; either version 2 of the License, or
  14 *  (at your option) any later version.
  15 *
  16 *  The software is distributed in the hope that it will be useful,
  17 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19 *  GNU General Public License for more details.
  20 *
  21 *  You should have received a copy of the GNU General Public License
  22 *  along with this software; if not, write to the Free Software
  23 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  24 *
  25*/
  26/*****************************************************************************/
  27
  28#include "easycap.h"
  29
  30/*---------------------------------------------------------------------------*/
  31/*
  32 *  THE LEAST SIGNIFICANT BIT OF easycap_standard.mask HAS MEANING:
  33 *                         0 => 25 fps
  34 *                         1 => 30 fps
  35 *
  36 *  THE MOST  SIGNIFICANT BIT OF easycap_standard.mask HAS MEANING:
  37 *                         0 => full framerate
  38 *                         1 => 20%  framerate
  39 */
  40/*---------------------------------------------------------------------------*/
  41const struct easycap_standard easycap_standard[] = {
  42        {
  43                .mask = 0x00FF & PAL_BGHIN ,
  44                .v4l2_standard = {
  45                        .index = PAL_BGHIN,
  46                        .id = (V4L2_STD_PAL_B |
  47                                V4L2_STD_PAL_G | V4L2_STD_PAL_H |
  48                                V4L2_STD_PAL_I | V4L2_STD_PAL_N),
  49                        .name = "PAL_BGHIN",
  50                        .frameperiod = {1, 25},
  51                        .framelines = 625,
  52                        .reserved = {0, 0, 0, 0}
  53                }
  54        },
  55/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  56        {
  57                .mask = 0x00FF & NTSC_N_443 ,
  58                .v4l2_standard = {
  59                        .index = NTSC_N_443,
  60                        .id = V4L2_STD_UNKNOWN,
  61                        .name = "NTSC_N_443",
  62                        .frameperiod = {1, 25},
  63                        .framelines = 480,
  64                        .reserved = {0, 0, 0, 0}
  65                }
  66        },
  67/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  68        {
  69                .mask = 0x00FF & PAL_Nc ,
  70                .v4l2_standard = {
  71                        .index = PAL_Nc,
  72                        .id = V4L2_STD_PAL_Nc,
  73                        .name = "PAL_Nc",
  74                        .frameperiod = {1, 25},
  75                        .framelines = 625,
  76                        .reserved = {0, 0, 0, 0}
  77                }
  78        },
  79/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  80        {
  81                .mask = 0x00FF & NTSC_N ,
  82                .v4l2_standard = {
  83                        .index = NTSC_N,
  84                        .id = V4L2_STD_UNKNOWN,
  85                        .name = "NTSC_N",
  86                        .frameperiod = {1, 25},
  87                        .framelines = 525,
  88                        .reserved = {0, 0, 0, 0}
  89                }
  90        },
  91/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  92        {
  93                .mask = 0x00FF & SECAM ,
  94                .v4l2_standard = {
  95                        .index = SECAM,
  96                        .id = V4L2_STD_SECAM,
  97                        .name = "SECAM",
  98                        .frameperiod = {1, 25},
  99                        .framelines = 625,
 100                        .reserved = {0, 0, 0, 0}
 101                }
 102        },
 103/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 104        {
 105                .mask = 0x00FF & NTSC_M ,
 106                .v4l2_standard = {
 107                        .index = NTSC_M,
 108                        .id = V4L2_STD_NTSC_M,
 109                        .name = "NTSC_M",
 110                        .frameperiod = {1, 30},
 111                        .framelines = 525,
 112                        .reserved = {0, 0, 0, 0}
 113                }
 114        },
 115/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 116        {
 117                .mask = 0x00FF & NTSC_M_JP ,
 118                .v4l2_standard = {
 119                        .index = NTSC_M_JP,
 120                        .id = V4L2_STD_NTSC_M_JP,
 121                        .name = "NTSC_M_JP",
 122                        .frameperiod = {1, 30},
 123                        .framelines = 525,
 124                        .reserved = {0, 0, 0, 0}
 125                }
 126        },
 127/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 128        {
 129                .mask = 0x00FF & PAL_60 ,
 130                .v4l2_standard = {
 131                        .index = PAL_60,
 132                        .id = V4L2_STD_PAL_60,
 133                        .name = "PAL_60",
 134                        .frameperiod = {1, 30},
 135                        .framelines = 525,
 136                        .reserved = {0, 0, 0, 0}
 137                }
 138        },
 139/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 140        {
 141                .mask = 0x00FF & NTSC_443 ,
 142                .v4l2_standard = {
 143                        .index = NTSC_443,
 144                        .id = V4L2_STD_NTSC_443,
 145                        .name = "NTSC_443",
 146                        .frameperiod = {1, 30},
 147                        .framelines = 525,
 148                        .reserved = {0, 0, 0, 0}
 149                }
 150        },
 151/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 152        {
 153                .mask = 0x00FF & PAL_M ,
 154                .v4l2_standard = {
 155                        .index = PAL_M,
 156                        .id = V4L2_STD_PAL_M,
 157                        .name = "PAL_M",
 158                        .frameperiod = {1, 30},
 159                        .framelines = 525,
 160                        .reserved = {0, 0, 0, 0}
 161                }
 162        },
 163/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 164        {
 165                .mask = 0x8000 | (0x00FF & PAL_BGHIN_SLOW),
 166                .v4l2_standard = {
 167                        .index = PAL_BGHIN_SLOW,
 168                        .id = (V4L2_STD_PAL_B | V4L2_STD_PAL_G |
 169                                V4L2_STD_PAL_H |
 170                                V4L2_STD_PAL_I | V4L2_STD_PAL_N |
 171                                (((v4l2_std_id)0x01) << 32)),
 172                        .name = "PAL_BGHIN_SLOW",
 173                        .frameperiod = {1, 5},
 174                        .framelines = 625,
 175                        .reserved = {0, 0, 0, 0}
 176                }
 177        },
 178/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 179        {
 180                .mask = 0x8000 | (0x00FF & NTSC_N_443_SLOW),
 181                .v4l2_standard = {
 182                        .index = NTSC_N_443_SLOW,
 183                        .id = (V4L2_STD_UNKNOWN | (((v4l2_std_id)0x11) << 32)),
 184                        .name = "NTSC_N_443_SLOW",
 185                        .frameperiod = {1, 5},
 186                        .framelines = 480,
 187                        .reserved = {0, 0, 0, 0}
 188                }
 189        },
 190/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 191        {
 192                .mask = 0x8000 | (0x00FF & PAL_Nc_SLOW),
 193                .v4l2_standard = {
 194                        .index = PAL_Nc_SLOW,
 195                        .id = (V4L2_STD_PAL_Nc | (((v4l2_std_id)0x01) << 32)),
 196                        .name = "PAL_Nc_SLOW",
 197                        .frameperiod = {1, 5},
 198                        .framelines = 625,
 199                        .reserved = {0, 0, 0, 0}
 200                }
 201        },
 202/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 203        {
 204                .mask = 0x8000 | (0x00FF & NTSC_N_SLOW),
 205                .v4l2_standard = {
 206                        .index = NTSC_N_SLOW,
 207                        .id = (V4L2_STD_UNKNOWN | (((v4l2_std_id)0x21) << 32)),
 208                        .name = "NTSC_N_SLOW",
 209                        .frameperiod = {1, 5},
 210                        .framelines = 525,
 211                        .reserved = {0, 0, 0, 0}
 212                }
 213        },
 214/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 215        {
 216                .mask = 0x8000 | (0x00FF & SECAM_SLOW),
 217                .v4l2_standard = {
 218                        .index = SECAM_SLOW,
 219                        .id = (V4L2_STD_SECAM | (((v4l2_std_id)0x01) << 32)),
 220                        .name = "SECAM_SLOW",
 221                        .frameperiod = {1, 5},
 222                        .framelines = 625,
 223                        .reserved = {0, 0, 0, 0}
 224                }
 225        },
 226/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 227        {
 228                .mask = 0x8000 | (0x00FF & NTSC_M_SLOW),
 229                .v4l2_standard = {
 230                        .index = NTSC_M_SLOW,
 231                        .id = (V4L2_STD_NTSC_M | (((v4l2_std_id)0x01) << 32)),
 232                        .name = "NTSC_M_SLOW",
 233                        .frameperiod = {1, 6},
 234                        .framelines = 525,
 235                        .reserved = {0, 0, 0, 0}
 236                }
 237        },
 238/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 239        {
 240                .mask = 0x8000 | (0x00FF & NTSC_M_JP_SLOW),
 241                .v4l2_standard = {
 242                        .index = NTSC_M_JP_SLOW,
 243                        .id = (V4L2_STD_NTSC_M_JP |
 244                                (((v4l2_std_id)0x01) << 32)),
 245                        .name = "NTSC_M_JP_SLOW",
 246                        .frameperiod = {1, 6},
 247                        .framelines = 525,
 248                        .reserved = {0, 0, 0, 0}
 249                }
 250        },
 251/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 252        {
 253                .mask = 0x8000 | (0x00FF & PAL_60_SLOW),
 254                .v4l2_standard = {
 255                        .index = PAL_60_SLOW,
 256                        .id = (V4L2_STD_PAL_60 | (((v4l2_std_id)0x01) << 32)),
 257                        .name = "PAL_60_SLOW",
 258                        .frameperiod = {1, 6},
 259                        .framelines = 525,
 260                        .reserved = {0, 0, 0, 0}
 261                }
 262        },
 263/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 264        {
 265                .mask = 0x8000 | (0x00FF & NTSC_443_SLOW),
 266                .v4l2_standard = {
 267                        .index = NTSC_443_SLOW,
 268                        .id = (V4L2_STD_NTSC_443 | (((v4l2_std_id)0x01) << 32)),
 269                        .name = "NTSC_443_SLOW",
 270                        .frameperiod = {1, 6},
 271                        .framelines = 525,
 272                        .reserved = {0, 0, 0, 0}
 273                }
 274        },
 275/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 276        {
 277                .mask = 0x8000 | (0x00FF & PAL_M_SLOW),
 278                .v4l2_standard = {
 279                        .index = PAL_M_SLOW,
 280                        .id = (V4L2_STD_PAL_M | (((v4l2_std_id)0x01) << 32)),
 281                        .name = "PAL_M_SLOW",
 282                        .frameperiod = {1, 6},
 283                        .framelines = 525,
 284                        .reserved = {0, 0, 0, 0}
 285                }
 286        },
 287/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 288        {
 289                .mask = 0xFFFF
 290        }
 291};
 292/*---------------------------------------------------------------------------*/
 293/*
 294 *  THE 16-BIT easycap_format.mask HAS MEANING:
 295 *    (least significant) BIT  0:     0 => PAL, 25 FPS;   1 => NTSC, 30 FPS
 296 *                        BITS 2-4:   RESERVED FOR DIFFERENTIATING STANDARDS
 297 *                        BITS 5-7:   NUMBER OF BYTES PER PIXEL
 298 *                        BIT  8:     0 => NATIVE BYTE ORDER;  1 => SWAPPED
 299 *                        BITS 9-10:  RESERVED FOR OTHER BYTE PERMUTATIONS
 300 *                        BIT 11:     0 => UNDECIMATED;    1 => DECIMATED
 301 *                        BIT 12:     0 => OFFER FRAMES;   1 => OFFER FIELDS
 302 *                        BIT 13:     0 => FULL FRAMERATE; 1 => REDUCED
 303 *     (most significant) BITS 14-15: RESERVED FOR OTHER FIELD/FRAME OPTIONS
 304 *  IT FOLLOWS THAT:
 305 *     bytesperpixel IS         ((0x00E0 & easycap_format.mask) >> 5)
 306 *     byteswaporder IS true IF (0 != (0x0100 & easycap_format.mask))
 307 *
 308 *     decimatepixel IS true IF (0 != (0x0800 & easycap_format.mask))
 309 *
 310 *       offerfields IS true IF (0 != (0x1000 & easycap_format.mask))
 311 */
 312/*---------------------------------------------------------------------------*/
 313
 314struct easycap_format easycap_format[1 + SETTINGS_MANY];
 315
 316int fillin_formats(void)
 317{
 318        const char *name1, *name2, *name3, *name4;
 319        struct v4l2_format *fmt;
 320        int i, j, k, m, n;
 321        u32 width, height, pixelformat, bytesperline, sizeimage;
 322        u16 mask1, mask2, mask3, mask4;
 323        enum v4l2_field field;
 324        enum v4l2_colorspace colorspace;
 325
 326        for (i = 0, n = 0; i < STANDARD_MANY; i++) {
 327                mask1 = 0x0000;
 328                switch (i) {
 329                case PAL_BGHIN: {
 330                        mask1 = 0x1F & PAL_BGHIN;
 331                        name1 = "PAL_BGHIN";
 332                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 333                        break;
 334                }
 335                case SECAM: {
 336                        mask1 = 0x1F & SECAM;
 337                        name1 = "SECAM";
 338                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 339                        break;
 340                }
 341                case PAL_Nc: {
 342                        mask1 = 0x1F & PAL_Nc;
 343                        name1 = "PAL_Nc";
 344                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 345                        break;
 346                }
 347                case PAL_60: {
 348                        mask1 = 0x1F & PAL_60;
 349                        name1 = "PAL_60";
 350                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 351                        break;
 352                }
 353                case PAL_M: {
 354                        mask1 = 0x1F & PAL_M;
 355                        name1 = "PAL_M";
 356                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 357                        break;
 358                }
 359                case NTSC_M: {
 360                        mask1 = 0x1F & NTSC_M;
 361                        name1 = "NTSC_M";
 362                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 363                        break;
 364                }
 365                case NTSC_443: {
 366                        mask1 = 0x1F & NTSC_443;
 367                        name1 = "NTSC_443";
 368                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 369                        break;
 370                }
 371                case NTSC_M_JP: {
 372                        mask1 = 0x1F & NTSC_M_JP;
 373                        name1 = "NTSC_M_JP";
 374                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 375                        break;
 376                }
 377                case NTSC_N: {
 378                        mask1 = 0x1F & NTSC_M;
 379                        name1 = "NTSC_N";
 380                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 381                        break;
 382                }
 383                case NTSC_N_443: {
 384                        mask1 = 0x1F & NTSC_N_443;
 385                        name1 = "NTSC_N_443";
 386                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 387                        break;
 388                }
 389                case PAL_BGHIN_SLOW: {
 390                        mask1 = 0x001F & PAL_BGHIN_SLOW;
 391                        mask1 |= 0x0200;
 392                        name1 = "PAL_BGHIN_SLOW";
 393                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 394                        break;
 395                }
 396                case SECAM_SLOW: {
 397                        mask1 = 0x001F & SECAM_SLOW;
 398                        mask1 |= 0x0200;
 399                        name1 = "SECAM_SLOW";
 400                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 401                        break;
 402                }
 403                case PAL_Nc_SLOW: {
 404                        mask1 = 0x001F & PAL_Nc_SLOW;
 405                        mask1 |= 0x0200;
 406                        name1 = "PAL_Nc_SLOW";
 407                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 408                        break;
 409                }
 410                case PAL_60_SLOW: {
 411                        mask1 = 0x001F & PAL_60_SLOW;
 412                        mask1 |= 0x0200;
 413                        name1 = "PAL_60_SLOW";
 414                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 415                        break;
 416                }
 417                case PAL_M_SLOW: {
 418                        mask1 = 0x001F & PAL_M_SLOW;
 419                        mask1 |= 0x0200;
 420                        name1 = "PAL_M_SLOW";
 421                        colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
 422                        break;
 423                }
 424                case NTSC_M_SLOW: {
 425                        mask1 = 0x001F & NTSC_M_SLOW;
 426                        mask1 |= 0x0200;
 427                        name1 = "NTSC_M_SLOW";
 428                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 429                        break;
 430                }
 431                case NTSC_443_SLOW: {
 432                        mask1 = 0x001F & NTSC_443_SLOW;
 433                        mask1 |= 0x0200;
 434                        name1 = "NTSC_443_SLOW";
 435                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 436                        break;
 437                }
 438                case NTSC_M_JP_SLOW: {
 439                        mask1 = 0x001F & NTSC_M_JP_SLOW;
 440                        mask1 |= 0x0200;
 441                        name1 = "NTSC_M_JP_SLOW";
 442                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 443                        break;
 444                }
 445                case NTSC_N_SLOW: {
 446                        mask1 = 0x001F & NTSC_N_SLOW;
 447                        mask1 |= 0x0200;
 448                        name1 = "NTSC_N_SLOW";
 449                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 450                        break;
 451                }
 452                case NTSC_N_443_SLOW: {
 453                        mask1 = 0x001F & NTSC_N_443_SLOW;
 454                        mask1 |= 0x0200;
 455                        name1 = "NTSC_N_443_SLOW";
 456                        colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
 457                        break;
 458                }
 459                default:
 460                        return -1;
 461                }
 462
 463                for (j = 0; j < RESOLUTION_MANY; j++) {
 464                        mask2 = 0x0000;
 465                        switch (j) {
 466                        case AT_720x576: {
 467                                if (0x1 & mask1)
 468                                        continue;
 469                                name2 = "_AT_720x576";
 470                                width = 720;
 471                                height = 576;
 472                                break;
 473                        }
 474                        case AT_704x576: {
 475                                if (0x1 & mask1)
 476                                        continue;
 477                                name2 = "_AT_704x576";
 478                                width = 704;
 479                                height = 576;
 480                                break;
 481                        }
 482                        case AT_640x480: {
 483                                name2 = "_AT_640x480";
 484                                width = 640;
 485                                height = 480;
 486                                break;
 487                        }
 488                        case AT_720x480: {
 489                                if (!(0x1 & mask1))
 490                                        continue;
 491                                name2 = "_AT_720x480";
 492                                width = 720;
 493                                height = 480;
 494                                break;
 495                        }
 496                        case AT_360x288: {
 497                                if (0x1 & mask1)
 498                                        continue;
 499                                name2 = "_AT_360x288";
 500                                width = 360;
 501                                height = 288;
 502                                mask2 = 0x0800;
 503                                break;
 504                        }
 505                        case AT_320x240: {
 506                                name2 = "_AT_320x240";
 507                                width = 320;
 508                                height = 240;
 509                                mask2 = 0x0800;
 510                                break;
 511                        }
 512                        case AT_360x240: {
 513                                if (!(0x1 & mask1))
 514                                        continue;
 515                                name2 = "_AT_360x240";
 516                                width = 360;
 517                                height = 240;
 518                                mask2 = 0x0800;
 519                                break;
 520                        }
 521                        default:
 522                                return -2;
 523                        }
 524
 525                        for (k = 0; k < PIXELFORMAT_MANY; k++) {
 526                                mask3 = 0x0000;
 527                                switch (k) {
 528                                case FMT_UYVY: {
 529                                        name3 = __stringify(FMT_UYVY);
 530                                        pixelformat = V4L2_PIX_FMT_UYVY;
 531                                        mask3 |= (0x02 << 5);
 532                                        break;
 533                                }
 534                                case FMT_YUY2: {
 535                                        name3 = __stringify(FMT_YUY2);
 536                                        pixelformat = V4L2_PIX_FMT_YUYV;
 537                                        mask3 |= (0x02 << 5);
 538                                        mask3 |= 0x0100;
 539                                        break;
 540                                }
 541                                case FMT_RGB24: {
 542                                        name3 = __stringify(FMT_RGB24);
 543                                        pixelformat = V4L2_PIX_FMT_RGB24;
 544                                        mask3 |= (0x03 << 5);
 545                                        break;
 546                                }
 547                                case FMT_RGB32: {
 548                                        name3 = __stringify(FMT_RGB32);
 549                                        pixelformat = V4L2_PIX_FMT_RGB32;
 550                                        mask3 |= (0x04 << 5);
 551                                        break;
 552                                }
 553                                case FMT_BGR24: {
 554                                        name3 = __stringify(FMT_BGR24);
 555                                        pixelformat = V4L2_PIX_FMT_BGR24;
 556                                        mask3 |= (0x03 << 5);
 557                                        mask3 |= 0x0100;
 558                                        break;
 559                                }
 560                                case FMT_BGR32: {
 561                                        name3 = __stringify(FMT_BGR32);
 562                                        pixelformat = V4L2_PIX_FMT_BGR32;
 563                                        mask3 |= (0x04 << 5);
 564                                        mask3 |= 0x0100;
 565                                        break;
 566                                }
 567                                default:
 568                                        return -3;
 569                                }
 570                                bytesperline = width * ((mask3 & 0x00F0) >> 4);
 571                                sizeimage =  bytesperline * height;
 572
 573                                for (m = 0; m < INTERLACE_MANY; m++) {
 574                                        mask4 = 0x0000;
 575                                        switch (m) {
 576                                        case FIELD_NONE: {
 577                                                name4 = "-n";
 578                                                field = V4L2_FIELD_NONE;
 579                                                break;
 580                                        }
 581                                        case FIELD_INTERLACED: {
 582                                                name4 = "-i";
 583                                                mask4 |= 0x1000;
 584                                                field = V4L2_FIELD_INTERLACED;
 585                                                break;
 586                                        }
 587                                        default:
 588                                                return -4;
 589                                        }
 590                                        if (SETTINGS_MANY <= n)
 591                                                return -5;
 592
 593                                        strcpy(easycap_format[n].name, name1);
 594                                        strcat(easycap_format[n].name, name2);
 595                                        strcat(easycap_format[n].name, "_");
 596                                        strcat(easycap_format[n].name, name3);
 597                                        strcat(easycap_format[n].name, name4);
 598                                        easycap_format[n].mask =
 599                                                mask1 | mask2 | mask3 | mask4;
 600                                        fmt = &easycap_format[n].v4l2_format;
 601
 602                                        fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 603                                        fmt->fmt.pix.width = width;
 604                                        fmt->fmt.pix.height = height;
 605                                        fmt->fmt.pix.pixelformat = pixelformat;
 606                                        fmt->fmt.pix.field = field;
 607                                        fmt->fmt.pix.bytesperline = bytesperline;
 608                                        fmt->fmt.pix.sizeimage = sizeimage;
 609                                        fmt->fmt.pix.colorspace = colorspace;
 610                                        fmt->fmt.pix.priv = 0;
 611                                        n++;
 612                                }
 613                        }
 614                }
 615        }
 616        if ((1 + SETTINGS_MANY) <= n)
 617                return -6;
 618        easycap_format[n].mask = 0xFFFF;
 619        return n;
 620}
 621/*---------------------------------------------------------------------------*/
 622struct v4l2_queryctrl easycap_control[] = {
 623        {
 624                .id       = V4L2_CID_BRIGHTNESS,
 625                .type     = V4L2_CTRL_TYPE_INTEGER,
 626                .name     = "Brightness",
 627                .minimum  = 0,
 628                .maximum  = 255,
 629                .step     =  1,
 630                .default_value = SAA_0A_DEFAULT,
 631                .flags    = 0,
 632                .reserved = {0, 0}
 633        },
 634/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 635        {
 636                .id       = V4L2_CID_CONTRAST,
 637                .type     = V4L2_CTRL_TYPE_INTEGER,
 638                .name     = "Contrast",
 639                .minimum  = 0,
 640                .maximum  = 255,
 641                .step     =   1,
 642                .default_value = SAA_0B_DEFAULT + 128,
 643                .flags    = 0,
 644                .reserved = {0, 0}
 645        },
 646/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 647        {
 648                .id       = V4L2_CID_SATURATION,
 649                .type     = V4L2_CTRL_TYPE_INTEGER,
 650                .name     = "Saturation",
 651                .minimum  = 0,
 652                .maximum  = 255,
 653                .step     =   1,
 654                .default_value = SAA_0C_DEFAULT + 128,
 655                .flags    = 0,
 656                .reserved = {0, 0}
 657        },
 658/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 659        {
 660                .id       = V4L2_CID_HUE,
 661                .type     = V4L2_CTRL_TYPE_INTEGER,
 662                .name     = "Hue",
 663                .minimum  = 0,
 664                .maximum  = 255,
 665                .step     =   1,
 666                .default_value = SAA_0D_DEFAULT + 128,
 667                .flags    = 0,
 668                .reserved = {0, 0}
 669        },
 670/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 671        {
 672                .id       = V4L2_CID_AUDIO_VOLUME,
 673                .type     = V4L2_CTRL_TYPE_INTEGER,
 674                .name     = "Volume",
 675                .minimum  = 0,
 676                .maximum  = 31,
 677                .step     =   1,
 678                .default_value = 16,
 679                .flags    = 0,
 680                .reserved = {0, 0}
 681        },
 682/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 683        {
 684                .id       = V4L2_CID_AUDIO_MUTE,
 685                .type     = V4L2_CTRL_TYPE_BOOLEAN,
 686                .name     = "Mute",
 687                .default_value = true,
 688                .flags    = 0,
 689                .reserved = {0, 0}
 690        },
 691/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 692        {
 693                .id = 0xFFFFFFFF
 694        }
 695};
 696/*****************************************************************************/
 697