mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
use hdparm to set speedcontrol.
This commit is contained in:
parent
134864b4c2
commit
2c4b27b9d3
@ -24,7 +24,7 @@ PKG_LICENSE="GPL"
|
||||
PKG_SITE="http://www.busybox.net"
|
||||
PKG_URL="http://busybox.net/downloads/$PKG_NAME-$PKG_VERSION.tar.bz2"
|
||||
PKG_DEPENDS_HOST=""
|
||||
PKG_DEPENDS_TARGET="toolchain busybox:host hdparm dosfstools e2fsprogs speedcontrol zip unzip pciutils usbutils parted"
|
||||
PKG_DEPENDS_TARGET="toolchain busybox:host hdparm dosfstools e2fsprogs zip unzip pciutils usbutils parted"
|
||||
PKG_DEPENDS_INIT="toolchain"
|
||||
PKG_PRIORITY="required"
|
||||
PKG_SECTION="system"
|
||||
|
@ -1,42 +0,0 @@
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||
#
|
||||
# OpenELEC 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.
|
||||
#
|
||||
# OpenELEC 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 OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
PKG_NAME="speedcontrol"
|
||||
PKG_VERSION="1"
|
||||
PKG_REV="1"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="http://noto.de"
|
||||
PKG_URL=""
|
||||
PKG_DEPENDS_TARGET="toolchain"
|
||||
PKG_PRIORITY="optional"
|
||||
PKG_SECTION="system"
|
||||
PKG_SHORTDESC="speedcontrol: a tool to setup cdrom drive speed"
|
||||
PKG_LONGDESC="speedcontrol is a tool to setup cdrom drive speed"
|
||||
|
||||
PKG_IS_ADDON="no"
|
||||
PKG_AUTORECONF="no"
|
||||
|
||||
make_target() {
|
||||
$CC $CFLAGS $LDFLAGS -o $PKG_NAME $PKG_NAME.c
|
||||
}
|
||||
|
||||
makeinstall_target() {
|
||||
mkdir -p $INSTALL/usr/bin
|
||||
cp $PKG_NAME $INSTALL/usr/bin
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* SpeedControl - 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., 51 Franklin Street, Suite 500, Boston, MA 02110, 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: speedcontrol [-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;
|
||||
}
|
||||
|
@ -20,6 +20,6 @@
|
||||
ACTION!="add|change", GOTO="cdrom_end"
|
||||
|
||||
# set CDROM speed
|
||||
KERNEL=="sr*", RUN+="/usr/bin/speedcontrol -x8 /dev/%k"
|
||||
KERNEL=="sr*", RUN+="/sbin/hdparm -E8 /dev/%k"
|
||||
|
||||
LABEL="cdrom_end"
|
Loading…
x
Reference in New Issue
Block a user