linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Re: Is controlling DVD speeds via SET_STREAMING supported?
@ 2004-11-24 22:16 Thomas Fritzsche
  2004-11-25  7:56 ` Jens Axboe
  2004-11-25  8:04 ` Jens Axboe
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Fritzsche @ 2004-11-24 22:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: david, axboe

Hi David,

I had the same problem with my DVD+-RW NEC-ND 3500 (NEC-support told me
that they didn't support linux :-( ). After googling I couldn't find an
answer. Because I didn't know anything about ide-cd (yesterday ;-))  I
read in this spec about the SET STREAMING command:
ftp://ftp.avc-pioneer.com/Mtfuji_4/Spec/Fuji4r10.pdf
If you also read the newer Specs (Mtfuji_5) then you'll find out that the
"SET CD SPEED" command is "only applicable to CD-R/RW logical units".
It looks like older DVD-Drives also support this command, but newer do not
support this for DVD+-R. But there is also the SET STREAMING command as
Jens Axboe described on this list. Not all devices support this feature
but my NEC-CD 3500 does (as I found out ;-) / my Teac-CD-RW does not)

I wrote a little programm to test this SET STREAMING command (quick &
dirty). In my opinion it would make sence to also enhance the kernel
function cdrom_select_speed (linux/drivers/ide/ide-cd.c), so that this
function works also for "newer" DVD-drives.
(!first check for the Realtime-Streaming-Feature and then use the right
command to set the speed). Because DVD+-RW Drives will be faster (AND
LOUDER!!) very soon it would be nice to have this in the kernel.

Thanks and regards,
 Thomas Fritzsche

PS.: I'm not subscribed to LKML please CC me If you would like to discuss
this issue.

-----------------------------------------
#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@noto.de>
 *
 *   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;

  while((c=getopt(argc,argv,"x:"))!=EOF) {
    switch(c) {
      case 'x': speed = atoi(optarg); break;
      default:
        printf("Usage: speed -x <speed>");
        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;
  }
}


-----------------------------------------

----------------------------------------------------------
Date	Sun, 21 Nov 2004 00:50:32 +0100
From	David Härdeman <>
Subject	Re: Is controlling DVD speeds via SET_STREAMING supported?

On Sat, Nov 20, 2004 at 09:19:45PM +0100, Jens Axboe wrote:
>On Sat, Nov 20 2004, David Härdeman wrote:
>> So, my question is, is this implemented in the kernel and are there any
>> userspace tools to set the playback speed?
>
>I don't know of any, but it is trival to write using SG_IO (or just
>CDROM_SEND_PACKET for this simple use, since only a trivial amount of
>data involved). If you are not sure how to do it, let me know and I can
>easily write one in minutes.

If you could write up a quick-n-dirty tool, it would be great! Based
on that I could hopefully write a patch later for one of the common
tools (eg. hdparm or setcd).

Re¸
David


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: Is controlling DVD speeds via SET_STREAMING supported?
  2004-11-24 22:16 Re: Is controlling DVD speeds via SET_STREAMING supported? Thomas Fritzsche
@ 2004-11-25  7:56 ` Jens Axboe
  2004-11-25  8:04 ` Jens Axboe
  1 sibling, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2004-11-25  7:56 UTC (permalink / raw)
  To: Thomas Fritzsche; +Cc: linux-kernel, david

On Wed, Nov 24 2004, Thomas Fritzsche wrote:
> Hi David,
> 
> I had the same problem with my DVD+-RW NEC-ND 3500 (NEC-support told me
> that they didn't support linux :-( ). After googling I couldn't find an
> answer. Because I didn't know anything about ide-cd (yesterday ;-))  I
> read in this spec about the SET STREAMING command:
> ftp://ftp.avc-pioneer.com/Mtfuji_4/Spec/Fuji4r10.pdf
> If you also read the newer Specs (Mtfuji_5) then you'll find out that the
> "SET CD SPEED" command is "only applicable to CD-R/RW logical units".
> It looks like older DVD-Drives also support this command, but newer do not
> support this for DVD+-R. But there is also the SET STREAMING command as
> Jens Axboe described on this list. Not all devices support this feature
> but my NEC-CD 3500 does (as I found out ;-) / my Teac-CD-RW does not)
> 
> I wrote a little programm to test this SET STREAMING command (quick &
> dirty). In my opinion it would make sence to also enhance the kernel
> function cdrom_select_speed (linux/drivers/ide/ide-cd.c), so that this
> function works also for "newer" DVD-drives.
> (!first check for the Realtime-Streaming-Feature and then use the right
> command to set the speed). Because DVD+-RW Drives will be faster (AND
> LOUDER!!) very soon it would be nice to have this in the kernel.

I agree, I'll do a patch for this right now. Your example code looks
fine. My only worry is that some drives might complain if your end_lba
is larger than the capacity, I'll have to double check the spec.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: Is controlling DVD speeds via SET_STREAMING supported?
  2004-11-24 22:16 Re: Is controlling DVD speeds via SET_STREAMING supported? Thomas Fritzsche
  2004-11-25  7:56 ` Jens Axboe
@ 2004-11-25  8:04 ` Jens Axboe
  2004-11-25  9:22   ` Thomas Fritzsche
  1 sibling, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2004-11-25  8:04 UTC (permalink / raw)
  To: Thomas Fritzsche; +Cc: linux-kernel, david

On Wed, Nov 24 2004, Thomas Fritzsche wrote:
>  /* 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;

I should have read this more closely... You need to fill the speed
fields correctly:

	unsigned long read_size = 177 * speed;

	buffer[12] = (read_size >> 24) & 0xff;
	buffer[13] = (read_size >> 16) & 0xff;
	buffer[14] = (read_size >>  8) & 0xff;
	buffer[15] = read_size & 0xff;

Ditto for write size.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: Is controlling DVD speeds via SET_STREAMING supported?
  2004-11-25  8:04 ` Jens Axboe
@ 2004-11-25  9:22   ` Thomas Fritzsche
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Fritzsche @ 2004-11-25  9:22 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Thomas Fritzsche, linux-kernel, david

Hi Jens,

absolute correct! I just tested it with speed = 1 yesterday night
(quick&duty). This is just a code snap to show that it's possible to set
the speed of a DVD drive this way.

You also wrote about the "End LBA" field in your other mail.
I set this to 0xffffffff but you think that this could be a problem if the
device don't have this LBA. The spec only writes this:
"The End LBA field is the last logical block for which the performance
request is being made." So it should be standard conform if we set here a
higher block number. Do you have experience with other (than NEC ND-3500)
drive that don't support this?

Using this high last block number would make sence, because it looks like
this setting is still valid if the media is changed (other end block!?).

Spec:
"The performance setting is persistent and remains until a new descriptor
is sent. The setting only applies to the extent
identified by the Start and End LBA field. Only zero or one performance
extents shall be valid at any time."

What do you think?

I also found out, that the Realtime-Streaming Feature is mandatory
for all kinds of DVD-+R+-RW-RAM drives. So it might be sufficient to
simply use SET STREAMING for DVD drives and SET SPEED for CD-R's. Isn't
it?

I will also enhance this tool by setting the RDD flag if the user selects
speed = 0.

Thanks and kind regards,
 Thomas Fritzsche

> I should have read this more closely... You need to fill the speed
> fields correctly:
>
> 	unsigned long read_size = 177 * speed;
>
> 	buffer[12] = (read_size >> 24) & 0xff;
> 	buffer[13] = (read_size >> 16) & 0xff;
> 	buffer[14] = (read_size >>  8) & 0xff;
> 	buffer[15] = read_size & 0xff;
>
> Ditto for write size.
>
> --
> Jens Axboe
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: Is controlling DVD speeds via SET_STREAMING supported?
  2004-11-26 19:59 Thomas Fritzsche
@ 2004-11-27  9:54 ` Thomas Fritzsche
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Fritzsche @ 2004-11-27  9:54 UTC (permalink / raw)
  To: linux-kernel

Hi Jens,

I build a new version that addresse this issues.

Usage: speed -x <speed> <device>
(speed = 0 means reset to defaults)

Cheers,
 Thomas Fritzsche

http://noto.de/vdr/speed-1.0.c
-------------------------------------------------------
/*
 * speed - use SET STREAMING command to set the speed of DVD-drives
 *
 *
 * Copyright (c) 2004	Thomas Fritzsche <tf@noto.de>
 *
 *   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.
 *
 */

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


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[])
{
  char *device = "/dev/cdrom";
  int c,fd;
  int speed = 0;
  unsigned long rw_size;

  unsigned char buffer[28];

  struct cdrom_generic_command cgc;
  struct request_sense sense;
  extern char * optarg;

  while((c=getopt(argc,argv,"x:"))!=EOF) {
    switch(c) {
      case 'x': speed = atoi(optarg); break;
      default:
        printf("Usage: speed [-x speed] [device]");
        return -1;
    }
  }

  if (argc > optind) device = argv[optind];

  fd = open(device, O_RDONLY | O_NONBLOCK);
  if (fd < 0) {
    printf("Can't open device %s\n", device);
    return -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;
  cgc.quiet = 1;

  if(speed == 0) {
/* set Restore Drive Defaults */
    buffer[0] = 4;
  }

  buffer[8] = 0xff;
  buffer[9] = 0xff;
  buffer[10] = 0xff;
  buffer[11] = 0xff;

  rw_size = 177 * speed;

/* read size */
  buffer[12] = (rw_size >> 24) & 0xff;
  buffer[13] = (rw_size >> 16) & 0xff;
  buffer[14] = (rw_size >>  8) & 0xff;
  buffer[15] = rw_size & 0xff;

/* read time 1 sec. */
  buffer[18] = 0x03;
  buffer[19] = 0xE8;

/* write size */
  buffer[20] = (rw_size >> 24) & 0xff;
  buffer[21] = (rw_size >> 16) & 0xff;
  buffer[22] = (rw_size >>  8) & 0xff;
  buffer[23] = rw_size & 0xff;

/* write time 1 sec. */
  buffer[26] = 0x03;
  buffer[27] = 0xE8;

  if (ioctl(fd, CDROM_SEND_PACKET, &cgc) != 0)
    if (ioctl(fd, CDROM_SELECT_SPEED, speed) != 0) {
      dump_sense(cgc.cmd, cgc.sense);
      printf("ERROR.\n");
      return -1;
    }
  printf("OK...\n");
  return 0;
}
-------------------------------------------------------

> Hi Jens,
>
> absolute correct! I just tested it with speed = 1 yesterday night
> (quick&duty). This is just a code snap to show that it's possible to set
> the speed of a DVD drive this way.
>
> You also wrote about the "End LBA" field in your other mail.
> I set this to 0xffffffff but you think that this could be a problem if the
> device don't have this LBA. The spec only writes this:
> "The End LBA field is the last logical block for which the performance
> request is being made." So it should be standard conform if we set here a
> higher block number. Do you have experience with other (than NEC ND-3500)
> drive that don't support this?
>
> Using this high last block number would make sence, because it looks like
> this setting is still valid if the media is changed (other end block!?).
>
> Spec:
> "The performance setting is persistent and remains until a new descriptor
> is sent. The setting only applies to the extent
> identified by the Start and End LBA field. Only zero or one performance
> extents shall be valid at any time."
>
> What do you think?
>
> I also found out, that the Realtime-Streaming Feature is mandatory for all
> kinds of DVD-+R+-RW-RAM drives. So it might be sufficient to simply use
> SET STREAMING for DVD drives and SET SPEED for CD-R's. Isn't it?
>
> I will also enhance this tool by setting the RDD flag if the user selects
> speed = 0.
>
> Thanks and kind regards,
>  Thomas Fritzsche
>
>> I should have read this more closely... You need to fill the speed
> fields correctly:
>>
>> 	unsigned long read_size = 177 * speed;
>>
>> 	buffer[12] = (read_size >> 24) & 0xff;
>> 	buffer[13] = (read_size >> 16) & 0xff;
>> 	buffer[14] = (read_size >>  8) & 0xff;
>> 	buffer[15] = read_size & 0xff;
>>
>> Ditto for write size.
>>
>> --
>> Jens Axboe
>>
>>
>
>
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: Is controlling DVD speeds via SET_STREAMING supported?
@ 2004-11-26 19:59 Thomas Fritzsche
  2004-11-27  9:54 ` Thomas Fritzsche
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Fritzsche @ 2004-11-26 19:59 UTC (permalink / raw)
  To: linux-kernel

Hi Jens,

absolute correct! I just tested it with speed = 1 yesterday night
(quick&duty). This is just a code snap to show that it's possible to set
the speed of a DVD drive this way.

You also wrote about the "End LBA" field in your other mail.
I set this to 0xffffffff but you think that this could be a problem if the
device don't have this LBA. The spec only writes this:
"The End LBA field is the last logical block for which the performance
request is being made." So it should be standard conform if we set here a
higher block number. Do you have experience with other (than NEC ND-3500)
drive that don't support this?

Using this high last block number would make sence, because it looks like
this setting is still valid if the media is changed (other end block!?).

Spec:
"The performance setting is persistent and remains until a new descriptor
is sent. The setting only applies to the extent
identified by the Start and End LBA field. Only zero or one performance
extents shall be valid at any time."

What do you think?

I also found out, that the Realtime-Streaming Feature is mandatory for all
kinds of DVD-+R+-RW-RAM drives. So it might be sufficient to simply use
SET STREAMING for DVD drives and SET SPEED for CD-R's. Isn't it?

I will also enhance this tool by setting the RDD flag if the user selects
speed = 0.

Thanks and kind regards,
 Thomas Fritzsche

> I should have read this more closely... You need to fill the speed
fields correctly:
>
> 	unsigned long read_size = 177 * speed;
>
> 	buffer[12] = (read_size >> 24) & 0xff;
> 	buffer[13] = (read_size >> 16) & 0xff;
> 	buffer[14] = (read_size >>  8) & 0xff;
> 	buffer[15] = read_size & 0xff;
>
> Ditto for write size.
>
> --
> Jens Axboe
>
>





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-11-27 11:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-24 22:16 Re: Is controlling DVD speeds via SET_STREAMING supported? Thomas Fritzsche
2004-11-25  7:56 ` Jens Axboe
2004-11-25  8:04 ` Jens Axboe
2004-11-25  9:22   ` Thomas Fritzsche
2004-11-26 19:59 Thomas Fritzsche
2004-11-27  9:54 ` Thomas Fritzsche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).