cdrom rychlost

Jan Gregor gregor.jan na NOSPAMquick.cz
Čtvrtek Listopad 17 10:43:18 CET 2005


mam stejneho NECa, pred casem jsem trochu badal ...
a rychlost se nastavuje pro CD i DVD jinak, proc to delat
stejne ;-))

prikladam programek na ovladani rychlosti dvd,
je dobre ho pustit pred mountovanim a vlozenem dvd.


Honza



#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>

/*
* speed - use SET STREAMING command to set the speed of DVD-drives
*
*
* Copyright (c) 2004 Thomas Fritzsche <tf na xxxxxxx>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/

void
dump_sense (unsigned char *cdb, struct request_sense *sense)
{
  int i;
  printf ("Command failed: ");
  for (i = 0; i < 12; i++)
    printf ("%02x ", cdb[i]);
  if (sense)
    {
      printf (" - sense: %02x.%02x.%02x\n", sense->sense_key, sense->asc,
              sense->ascq);
    }
  else
    {
      printf (", no sense\n");
    }
}

int
main (int argc, char *argv[])
{
  int fd = open ("/dev/hdc", O_RDONLY | O_NONBLOCK);
  int c;
  int speed = 0;
  unsigned char buffer[28];
  struct cdrom_generic_command cgc;
  struct request_sense sense;
  extern char *optarg;

  if (argc==1){
      printf ("Usage: speed -x <speed>\n");
      exit (-1);
  }  
  
  while ((c = getopt (argc, argv, "x:")) != EOF)
    {
      switch (c)
        {
        case 'x':
          speed = atoi (optarg);
          break;
        default:
          printf ("Usage: speed -x <speed>\n");
          exit (-1);
        }
    }
  memset (&cgc, 0, sizeof (cgc));
  memset (&sense, 0, sizeof (sense));
  memset (&buffer, 0, sizeof (buffer));

/* SET STREAMING command */
  cgc.cmd[0] = 0xb6;

/* 28 byte parameter list length */
  cgc.cmd[10] = 28;
  cgc.sense = &sense;
  cgc.buffer = buffer;
  cgc.buflen = sizeof (buffer);
  cgc.data_direction = CGC_DATA_WRITE;
  buffer[8] = 0xff;
  buffer[9] = 0xff;
  buffer[10] = 0xff;
  buffer[11] = 0xff;
  buffer[15] = 177 * speed;
  buffer[18] = 0x03;
  buffer[19] = 0xE8;
  buffer[23] = 177 * speed;
  buffer[26] = 0x03;
  buffer[27] = 0xE8;
  if (ioctl (fd, CDROM_SEND_PACKET, &cgc) == 0)
    {
      printf ("OK\n");
      return 0;
    }
  else

    {
      printf ("error!\n");
      dump_sense (cgc.cmd, cgc.sense);
      return -1;
    }
}

In article <dlc7dr$6fn$2 na crax.cesnet.cz>, Tosuja wrote:
> Mimochodem, funguje nekomu to nastavovani rychlosti spolehlive na DVD 
> mechanikach? Mam starsi slotovou DVD-ROM Pioneer a vypalovacku NEC 3520 a 
> nastaveni rychlosti sice neco dela (snad...), protoze zvuk mechaniky se 
> trosku zmeni, ale ze bych dokazal urcit, jak se zmenila rychlost, to ne...
> 
> Tosuja


Další informace o konferenci Linux